Show default gateway in textbox
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts
Page 1 of 1
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
this works
Code: Select all
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
Find my programs on Softpedia
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023