vb.net display User IP address code

Source: Internet
Author: User
Tags chr tostring

Get current computer name: System.net.dns.gethostname ()

Remove all IP address according to computer name: System.net.dns.resolve (computer name). AddressList or

System.net.dns.gethostbyname (computer name). AddressList Remove computer name from IP address

: System.net.dns.resolve (IP address). Hostname below we will use an example to see how to obtain

Take the IP address of this machine and get our host name.

<%@ page Language=vb debug=true%>
<script runat=server>
Sub Page_Load (ByVal sender As Object, ByVal e As EventArgs)
Lblmessage.text = "Your IP address:" _
& request.userhostaddress & "<br>" _
& "Your Host name:" _
& Request.userhostname & "<br>"
End Sub
<title>host and IP address</title>
<form runat= "Server" >
<asp Tutorial: Label
Id= "Lblmessage"
Font-size= "12pt"
Font-name= "Tahoma"
runat= "Server"

Application examples

Add the following code to the Form_Load event:

Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

Dim address () as System.Net.IPAddress

Dim i As Integer

Address = System.net.dns.gethostbyname (system.net.dns.gethostname

()). AddressList

TextBox1.Text = System.net.dns.gethostname (). ToString ()

For i = 0 To UBound (address)

TextBox2.Text = TextBox2.Text & Address (i). ToString () & Chr (+) + CHR



End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.