Parsing Problems

cbzdmh

Board Regular
Joined
Jul 16, 2007
Messages
58
Hi,
I've got the output from a ping command from which I want to extract the I.P. address. I can get it to work using several formula but want to be able to code it. How do I?

Output Text

Pinging PC.domain.net [128.58.42.10] with 32 bytes of data:
Reply from 128.58.42.10: bytes=32 time=6ms TTL=125
Ping statistics for 128.58.42.10:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 6ms, Maximum = 6ms, Average = 6ms

I tried the following code but it doesn't work:

From_Loc = Find("from", output, 1)
Space_Loc = Find(" ", output, From_Loc)
Colon_Loc = Find(":", output, Space_Loc)

IP = Mid(output, (From_Loc + 1), (Colon_Loc - Space_Loc - 1))
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
If output is the text, you can use Instr:
Code:
lngMatch = Instr(1, output, "Reply from ", vbTextCompare) + 11
to get the start of the IP address.
 
Upvote 0
Thank you very much, I'm sure ther's a more efficent version of this but this works.

ip_start = InStr(1, output, "Reply from ", vbTextCompare) + 11
ip_end = InStr(ip_start, output, ":", vbTextCompare)
Ip_Length = ip_end - ip_start

IP = Mid(output, ip_start, Ip_Length)
 
Upvote 0

Forum statistics

Threads
1,203,240
Messages
6,054,316
Members
444,717
Latest member
melindanegron

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top