How to Ping a Server From VB6

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

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.

Skill level:


  1. 1

    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.

  2. 2

    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.

  3. 3

    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.

  4. 4

    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

    MsgBox ping

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.