Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I manipulate string in vbscript

Status
Not open for further replies.

dorisr1

Programmer
May 20, 2008
3
CA
Hi,
I need to know how to manipulate string in vbscript...

I have something like this :

Mystring =" xxxxxx yyyyyyyyy zzzzzz"

I need to set values :
a=Mystring(2,6)
b=Mystring(10,9)
c=Mystring(26,6)
But this doesn't work... I tried substring but with no success...

I'm new to vbscripting... Can anyone help me on this case ?


Thanks
Doris
 
Look at Mid and Replace functions. Mid is probably the one you are looking for.

var = mid(myStr, Start, Length)

You could also strip the unneeded extra spaces then Split the string into an array...

Code:
Do Until InStr(myStr, "  ") = 0 [green]' Loop until no double spaces exist[/green]
    myStr = Replace(myStr, "  ", " ") [green]' Replace doubles with singles[/green]
Loop

arr = Split(myStr) [green]' Split on default delimeter (space)[/green]

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thanks PScottC,
Yes this will do the trick...

Thanks a lot,
Doris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top