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.
Printable View
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.
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"