Get IP and Host VB.NET

First, make the form as shown below

The Code Below
Imports System.Net
Imports System.IO
Public Class Form3
    Dim ip, host As String
    Sub CariHost_IP()
        host = Dns.GetHostName()
        ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(Function(a As IPAddress) Not a.IsIPv6LinkLocal AndAlso Not a.IsIPv6Multicast AndAlso Not a.IsIPv6SiteLocal).First().ToString()
    End Sub

    Private Sub btnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCari.Click
        Label3.Text = host
        Label4.Text = ip
    End Sub
End Class

0 komentar :

Posting Komentar

Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons