Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    27

    Unanswered: 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

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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....

  3. #3
    Join Date
    Jan 2004
    Posts
    27

    Smile

    Have it working now......Thanks very much*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •