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

Using PING in VBA

Status
Not open for further replies.

hochus

Programmer
Feb 1, 2001
6
US
Does anyone know how to use the PING function in VBA. I need to PING a remote system to make sure I have a connection prior to doing an FTP to that system. I need the PING to return one value if the PING is successful and another value if the PING is unsuccessful. If anyone knows how to do this or any other function to use, it would be GREATLY appreciated. Thanks.
 
Well this works but it opens a Command window ....
Not sure how to get back a value though.

Dim x As Variant, IPAddress As String
IPAddress = "10.0.0.51"
x = Shell("PING " & IPAddress, vbMaximizedFocus)
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Sorry I can't be more specific, but I'm not that familiar with batch programming.

To return a value, here is the only way that comes immediately to my mind (this is assuming there is a way to pass arguments to batch programs.. I really don't know):

- Write a batch (BAT) program which pings and writes the result to a text file (or better yet, have the program delete, say "Pingyes.txt" if it exists, then ping, then create "Pingyes.txt" if the Ping was successful).

- Call the shell program Doug mentions, except have it call the batch program, with the IP address as an argument (hopefully).

- Then:
dim bolPingSuccessful as boolean
const strPingIndicatorFile = "path\Pingyes.txt"

bolPingSuccessful = dir(strPingIndicatorFile) <> &quot;&quot;


Hope that was useful.. I don't know where you would look to find information on how to write the batch program, though.

Katie
 
Thank you both for your help. It seems to be working fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top