[dba-VB] Syslogs

jwcolby jwcolby at colbyconsulting.com
Tue Jun 30 11:43:40 CDT 2009


Yes, but then you have to do more.  IPConfig shows several IP addresses on my work laptop.  One is 
the wireless, which only works when in range of a wireless network, one is a physical NIC, and one 
is a Hamachi IP.  There could be even more.  On my server I have two physical NICS and in theory 
each could have asked for an IP address.

So would the REAL IP address please stand up.

John W. Colby
www.ColbyConsulting.com


Drew Wutka wrote:
> There are several ways to get your IP address.  Two I've used is to use
> a Winsock control, and look at the local host IP.
> 
> Another relatively easy way is to dump the results of IPCONFIG to a text
> file.
> 
> Create a .bat file (call it iptest.bat) and put the following line in
> it:
> 
> Ipconfig >C:\ip.txt
> 
> Then using ShellWait (http://mvps.org/access/api/api0004.htm)
> 
> Use this function:
> 
> Function IPAddresses() As String
> Dim f As Long
> Dim strTemp As String
> Dim strArray() As String
> If Dir("C:\ip.txt") <> "" Then Kill "C:\ip.txt"
> ShellWait "C:\iptest.bat"
> f = FreeFile
> Open "C:\ip.txt" For Binary Access Read As f
> strTemp = Space(LOF(f))
> Get f, , strTemp
> Close f
> strArray = Split(strTemp, vbCrLf)
> strTemp = ""
> For f = 0 To UBound(strArray)
>     If InStr(1, strArray(f), "IPv4", vbTextCompare) > 0 Or InStr(1,
> strArray(f), " IP Address", vbTextCompare) > 0 Then
>         strTemp = strTemp & Trim(Mid(strArray(f), InStr(1, strArray(f),
> ":", vbBinaryCompare) + 1)) & ";"
>     End If
> Next f
> If Len(strTemp) > 0 Then strTemp = Left(strTemp, Len(strTemp) - 1)
> IPAddresses = strTemp
> End Function
> 
> Whalla, IPAddresses will return as a semicolon delimited string.
> (Obviously you could return an array or create a collection too...either
> way....)
> 
> Drew




More information about the dba-VB mailing list