‘加一个 command
---------------------------------
Option Explicit
Private Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
Set objWMI = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colIP = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox "IP 地址:" & IP.IPAddress(I) & Chr(10) & "网卡类型:" & IP.Description(I) & Chr(10) & "网卡地址:" & IP.Macaddress(I)
Next
End If
Next
End Sub
Private Sub Command1_Click() '调用
GetMyIP
End Sub