If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > spliting a string

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-04, 12:36
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
spliting a string

When a new member is entered, I want to simultaneously create a new account for that member. The primary key in the ACCOUNT table is 'ACCOUNT_NUMBER' which is of the format A1, A2, A3 etc. What I want to so is to get the account number from the database, split it up into the letter and the number & then increment the number. The relevant code is below. Can anyone help me please.....

Code:
Dim aSQL
aSQL = "Select ACCOUNT_NUMBER From ACCOUNT"

Dim rsNo1
Set rsNo1 = Server.CreateObject("ADODB.Recordset")
rsNo1.CursorType = 2
rsNo1.LockType = 3
rsNo1.Open aSQL, adoCon

While NOT rsNo1.EOF
Dim accS 
	accS = rsNo1(0)

	Dim first
	x() = split(accS, "A")
	first = x(0)

	
	Dim second
	second = x(1)
Wend
Reply With Quote
  #2 (permalink)  
Old 03-01-04, 16:03
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Is the account number always a single letter then the number?? if so then why don't you just go....
Code:
While NOT rsNo1.EOF
Dim accS 
	accS = rsNo1(0)

	Dim first
	first = left(accS,1)
	
	Dim second
	second = mid(accS,2)
Wend
if the number of letters could increase then you need to do a search through the string for the first numeric character and the break the line on that point.

another thing, if the account letter prefix is always A then why worry about it at all. Forget first and just worry about second.

As for the incrementation a simple second = clng(second) + 1 should do the trick....
Reply With Quote
  #3 (permalink)  
Old 03-02-04, 05:24
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
Smile

Have it working now......Thanks very much*
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On