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

Get user's IP Address

Status
Not open for further replies.

Hfnet

IS-IT--Management
Dec 31, 2003
369
GB
I have found a module to retrieve the system IP adress of a machine, but on some systems (so far only 3 out of 35) it fails on line 3 of the code:

Code:
Public Function getMyIP()
    Dim myWMI As Object, myobj As Object, itm
    Set myWMI = GetObject("winmgmts:\\.\root\cimv2")
    Set myobj = myWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For Each itm In myobj
      getMyIP = itm.IPAddress(0)
      Exit Function
    Next
End Function

The error reported is error 91 - Object variable or with object variable not set.

What do I need to add to make this work on all machines?
 
no, I am missing references if I use the first code, and the second code is identical to the one I'm using anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top