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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a string for multiple values

Status
Not open for further replies.

mistux

MIS
Mar 27, 2003
10
0
0
US
I need to parse the following string:

"( B Panel 48.1248 X 93.5 CRS Gage 16)"

I need:
1. The letter preceding the word "Panel" in this case "B"
2. The number following the word "Panel" in this case "48.1248"
3. The number following the word "Gage" in this case "16"

Everything else "should" stay constant, i.e. the format. Although the actual values will change and the length of them.

I know that I can use InString, but the code is driving me crazy!

Can anyone help me?
 
This should do it for you as long as the format is exactly as you described including the parentheses. If the parentheses don't exist, you don't need to the second GageNumber assignment (line right above the Wscript.echo). If the space in front of the "B" doesn't exist either, you'll have to play around with the array element numbers. That is: PanelLetter=MyArray(0) instead of MyArray(1).

MyString = "( B Panel 48.1248 X 93.5 CRS Gage 16)"
MyArray=split(MyString," ")
PanelLetter=MyArray(1)
PanelNumber=MyArray(3)
GageNumber=MyArray(9)
GageNumber=left(GageNumber,len(GageNumber)-1)
wscript.echo "Panel Letter:"&PanelLetter&" Panel Number:"&PanelNumber&" Gage Number:"&GageNumber
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top