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

Parsing a txt line in VBScript

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How would I parse a text line that looks like "member 123.123.123.132:HTTP" into just 123.123.123.123?
The txt line is a var and I am trying to do this in a function.
Thanks
Arthur
 
Dim aryW

aryW = Split(strIn,":")
' * Prevent subscript out of range
if Ubound(aryW) < 1 then Redim Preserve aryW(1)
OR
Dim lngInstr
Dim strOut
lngInstr = Instr(1,strIn,&quot;:&quot;)
if lngInstr = 0 then
strOut = strIn
Else
strOut = Left(strIn, lngInstr - 1)
End if
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Try this

txt = &quot;member 123.123.123.132:HTTP&quot;
lenRev = InStrRev(txt, &quot;:&quot;, -1, 1)- 1
almost = left(txt, lenrev)
answer = Mid(almost, InStrRev(almost, &quot; &quot;, -1, 1) + 1)

msgbox answer



cornboy88
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top