通过VBA实现IP地址查询(固定)!
本帖最后由 作者 于 2010-5-10 9:27:20 编辑 <br /><br /> <p><font face="细明体" color="#000000" size="4">各位高手我有点事情想请教下,怎样在vba中用函数定义实现ip地址查询呢?<br/>也就是说我知道一些IP,怎样来判断它是南通或者北京(这些ip就是是南通和北京的)?<br/>怎么在vba里面实现啊!请指教我下。。。。</font></p><p></p><p>例子;</p><p>Public Sub GetMyIP()<br/> Dim strComputer As String<br/> Dim objWMI As Object<br/> Dim colIP As Object<br/> Dim IP As Object<br/> Dim i As Integer</p><p> strComputer = "."<br/> Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")<br/> Set colIP = objWMI.ExecQuery _<br/> ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")<br/> <br/> For Each IP In colIP<br/> If Not IsNull(IP.IPAddress) Then<br/> For i = LBound(IP.IPAddress) To UBound(IP.IPAddress)<br/> MsgBox IP.IPAddress(i), vbInformation, IP.Description(i)<br/> Next<br/> End If<br/> Next</p><p>End Sub</p><p>我只能查询本机的IP ,怎么才能实现查询访问的IP呢?并且进行对比。</p>
页:
[1]