Results 1 to 3 of 3

Thread: Splitting chars and numbers from string [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    The Netherlands
    Posts
    96

    Splitting chars and numbers from string [RESOLVED]

    I want to split some strings which look like this..

    10183bla.ini
    2972blokke.ini
    298dsfsdfds.ini

    I want to get them returned like below...Problem is I never know how many numbers and how many charachters will be in the string.

    10183 bla.ini
    2972 blokke.ini
    298 dsfsdfds.ini

    Anyone got any idea how to get this done?
    Last edited by Chrissie; Oct 19th, 2003 at 08:41 AM.

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Try something like this - I don't have VB on this box to test it.
    Code:
    Function reformat(str as string) as String
           Dim i as long
         
           i=1
           do while(ASC(mid(str,i,1)) < 65)
                 i = i + 1
           Loop
           reformat = left(str, i-1) & " " & right(str, len(str) -i)
    End Function

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    The Netherlands
    Posts
    96
    Thanks...that works for me...one small change...to make sure I get the full name.

    Code:
    Function reformat(str as string) as String
           Dim i as long
         
           i=1
           do while(ASC(mid(str,i,1)) < 65)
                 i = i + 1
           Loop
           reformat = left(str, i-1) & " " & right(str, len(str) -i+1)
    End Function

Posting Permissions

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



Click Here to Expand Forum to Full Width