Show default gateway in textbox
Posted: Sun Jan 20, 2013 1:09 pm
How can i obtain information about the default gateway so i can get it into a textbox so i get the propper value from the network adapter in use eg 255.255.255.0
Sharing, Teaching and Supporting coders of all ages and levels since 2009
https://www.codenstuff.com/forum/
Imports System.Net
Imports System.Net.NetworkInformation
'tested on shim aka the idiot
Public Class form1
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myNetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
Dim myAdapterProps As IPInterfaceProperties = Nothing
Dim myGateways As GatewayIPAddressInformationCollection = Nothing
For Each adapter As NetworkInterface In myNetworkAdapters
myAdapterProps = adapter.GetIPProperties
myGateways = myAdapterProps.GatewayAddresses
For Each Gateway As GatewayIPAddressInformation In myGateways
TextBox1.Text = ("Gateway IP: " & Gateway.Address.ToString)
Next
Next
End Sub
End Class