The Easiest Way to Get Local Ip Address (IPv4) in VB.Net

Submitted by: 
Visitors have accessed this post 135 times.

In this tutorial, I will teach you how to get the local ip address using visual basic 2015. This method has the ability to get your local ip address with ease. This simple program also illustrates how to retrieve Ipv4 and display it into the listbox.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for visual basic.

Step 2

Do the form just like shown below

Step 3

Open the code editor and set the Imports System.Net to access the .net libraries. You can put this above the public class.

Step 4

Create a sub procedure for getting the local ip address.

  1. Private Sub retrieve_ip()
  3. Dim host_name As String = Dns.GetHostName()
  5. Dim ip_address As String = Dns.GetHostByName(host_name).AddressList(0).ToString()
  7. ListBox1.Items.Add("Host: " & host_name & "; IP Address: " & ip_address)
  9. End Sub

Step 5
Do the following code for showing the ip address in the list box when the button is clicked.

  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. retrieve_ip()
  3. End Sub

For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.