Hi all,
I'm trying to amend the code below to help me get the IP address from my computer IPV4 so that I do not need to worry about the dynamic changes of IP addresses each time I log in
The code below works for me, but it brings the unwanted extension instead of just only the IPaddress.
I will be running this code on an onload event
Me.txtIpaddress = GetIPAddress()
help me to cut off fe80:::d90:56f:dca8:5bb510.212.128.10
I'm trying to amend the code below to help me get the IP address from my computer IPV4 so that I do not need to worry about the dynamic changes of IP addresses each time I log in
The code below works for me, but it brings the unwanted extension instead of just only the IPaddress.
Code:
Function GetIPAddress()
Const strComputer As String = "." ' Computer name. Dot means local computer
Dim objWMIService, IPConfigSet, IPConfig, IPAddress, i
Dim strIPAddress As String
' Connect to the WMI service
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Get all TCP/IP-enabled network adapters
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
' Get all IP addresses associated with these adapters
For Each IPConfig In IPConfigSet
IPAddress = IPConfig.IPAddress
If Not IsNull(IPAddress) Then
strIPAddress = strIPAddress & Join(IPAddress, ", ")
End If
Next
GetIPAddress = strIPAddress
End Function
I will be running this code on an onload event
Me.txtIpaddress = GetIPAddress()
help me to cut off fe80:::d90:56f:dca8:5bb510.212.128.10