05-15-2011, 06:15 PM
Gets the local gateway
Usage: MsgBox(localgateway)
Usage: MsgBox(localgateway)
Code:
Function localgateway() As String
Dim NetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
Dim myAdapterProps As IPInterfaceProperties = Nothing
Dim myGateways As GatewayIPAddressInformationCollection = Nothing
For Each adapter As NetworkInterface In NetworkAdapters
myAdapterProps = adapter.GetIPProperties
myGateways = myAdapterProps.GatewayAddresses
For Each Gateway As GatewayIPAddressInformation In myGateways
If Not Gateway.Address.ToString = "0.0.0.0" Then
Return (Gateway.Address.ToString)
Else
Return ("0.0.0.0")
End If
Next
Next
End Function