Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #114
Online Version at http://www.codeoftheweek.com/membersonly/bi/0114.html (paid subscribers only)
All content and source code is Copyright (c) 2000 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Determining IP addresses

Earn REAL money surfing the web!

If you would like to make some extra cash for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Get PAID for your code

We are currently looking for quality source code contributions for publication in Code of the Week. We are offering to pay from $25 to $200 for each submission we use. The amount primarily depends on the complexity of the source code. An issue like this one would be about $25 to $50. An issue like http://www.codeoftheweek.com/issues/0067.html would get $200 (maybe more).

If you have source code that you would like to submit, use our online submission form at http://www.codeoftheweek.com/submission.html

Be sure to fill out your name and address information so we can mail you your check upon publication.

Requirements

In this Issue

In this issue we discuss how to get the IP address from a domain name. This can be useful for debugging network problems. We have several issues planned to enhance this class to include ping and traceroute functions direct from Visual Basic. If you are interested in more details, contact ping@codeoftheweek.com

If you have any questions about using this module, let us know at questions@codeoftheweek.com

cICMP

This class module provides a simple way to get the IP address by name. If you use this function on the Internet it will figure out the IP address of a domain name. If you use it on your intranet it might return the name of a machine found in your hosts file. It uses the winsock libraries to gather this information.

Methods

Public Sub Initialize()

This method needs to be called before the any other routines in this class module. It is the one that initializes the winsock library.

Functions

Public Function GetIPAddress(ByVal sLookupName As String) As String

Returns the IP address of a network name (such as a domain name). For example codeoftheweek.com returns 216.149.93.134

Sample Usage

The below sample shows will determine the IP address of codeoftheweek.com.

    Dim ICMP As New cICMP

    ICMP.Initialize
    MsgBox "codeoftheweek.com IP address is " & ICMP.GetIPAddress("codeoftheweek.com")
    Set ICMP = Nothing

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0114.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com