You can use the Windows ICMP link library to ping an address in Visual Basic 6 (VB6). The DLL is included with the Windows operating system to handle networking requests for TCP/IP, which is the protocol used in internal networks and on the Internet. You must include the DLL in your VB6 code, ping the server and assign the results to a string.
Right-click the SLN file that contains your VB6 and click "Open With." Double-click the "Visual Basic" program displayed in the list of programs.
Right-click the form you want to use to ping the server. Copy and paste the following DLL link to the top of your VB6 file:
Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
These two DLLs provide the functions to ping and communicate over the TCP/IP protocol.
Ping the server. The following code pins the server:
Public Function ping("server", Reply As ICMP_ECHO_REPLY) As Long
Replace "server" with the name or IP address of the server. The replay is stored in the "echo reply" variable.
Print out the results from the ping. The following code sends the result to a string and displays the result in a message box:
Dim ping As String
ping = Reply.Status