Results 1 to 2 of 2

Thread: String parsing

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Posts
    80

    Post

    Hi,

    I'm much of a newbie when it comes to vb string parsing. Can some tell me how can I extract a certain number of characters from a string and store the remaining string somewhere else?

    What functions do I use?

    Thanks.

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Post

    Use the Mid Function!

    Eg

    dim MainStr as string

    dim NewString as string

    MainStr = "Hi, This is a string!"

    NewString = mid(MainStr, 5,3) 'returns 3 chrs from position 4

    'NewString now = "thi"

    ******************************

    If you want only the piece you didn't copy then you'll have to use left() and right() to grab the parts:

    NewString = left(MainStr,4) & right(MainStr,(len(MainStr) - 4 - 3) 'assuming you don't know the length of the MainStr, other wise you can skip the len(MainStr) bit and just specify the right portion

    NewString = "Hi, s is a string"



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