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!

Hopefully simple read file question 2

Status
Not open for further replies.

Smithsco

Technical User
Mar 30, 2003
89
AU
I have a file that will contain

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Minimum = 40ms, Maximum = 0ms, Average = 0ms

I want to just get the actual numbers out of each line and place them into a variable eg: oMin would be 40 etc
Any idea's
 
Open the file and read each line.

If the line contains "Minimum" then extract the number.

I assume your familiar with the filesystemobject. so...

If InStr(fso.ReadLine,"Minimum")>0 then
TextStr = fso.ReadLine

StartNo = InStr(TextStr,"Minimum") + 10
EndNo = InStr(TextStr,"ms")
oMin = Mid(TextStr,StartNo,EndNo-StartNo)
TextStr = RIGHT(TextStr,len(TextStr)-(EndNo+2))

StartNo = InStr(TextStr,"Maximum") + 10
EndNo = InStr(TextStr,"ms")
oMax = Mid(TextStr,StartNo,EndNo-StartNo)
TextStr = RIGHT(TextStr,len(TextStr)-(EndNo+2))

StartNo = InStr(TextStr,"Average") + 10
EndNo = InStr(TextStr,"ms")
oAve = Mid(TextStr,StartNo,EndNo-StartNo)
End If

BDC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top