473,545 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display my IP address?

cj
I can get my DNS Name, Machine Name and User Name like

MessageBox.Show ("NetBIOS Name: " & System.Environm ent.MachineName &
vbCrLf & _
"DNS Name: " & System.Net.Dns. GetHostByName(" LocalHost").Hos tName &
vbCrLf & _
"User Name: " & System.Environm ent.UserName)

how can I display my IP address?

Also, what is the difference between a DNS Name and a NetBIOS name?
May 22 '06 #1
11 22852
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function
"cj" <cj@nospam.nosp am> wrote in message
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
I can get my DNS Name, Machine Name and User Name like

MessageBox.Show ("NetBIOS Name: " & System.Environm ent.MachineName &
vbCrLf & _
"DNS Name: " & System.Net.Dns. GetHostByName(" LocalHost").Hos tName &
vbCrLf & _
"User Name: " & System.Environm ent.UserName)

how can I display my IP address?

Also, what is the difference between a DNS Name and a NetBIOS name?

May 22 '06 #2
Sam,

Maybe we should use System.Net.Dns. Resolve(System. Net.Dns.GetHost Name)
instead of
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName).

Peter

"Sam Malone" <th************ @hotmail.com>
wrote:#7******* *******@TK2MSFT NGP02.phx.gbl.. .
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function

May 23 '06 #3
Go for it and I'd appreciate hearing which is better (if indeed one is
better than the other)
"Peter" <zl*****@sina.c om> wrote in message
news:ed******** ******@TK2MSFTN GP04.phx.gbl...
Sam,

Maybe we should use System.Net.Dns. Resolve(System. Net.Dns.GetHost Name)
instead of
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName).

Peter

"Sam Malone" <th************ @hotmail.com>
wrote:#7******* *******@TK2MSFT NGP02.phx.gbl.. .
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function


May 23 '06 #4
cj
GetHostEntry is not a member of System.Net.Dns

Perhaps it's because I'm using VS2003?

Sam Malone wrote:
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function
"cj" <cj@nospam.nosp am> wrote in message
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
I can get my DNS Name, Machine Name and User Name like

MessageBox.Show ("NetBIOS Name: " & System.Environm ent.MachineName &
vbCrLf & _
"DNS Name: " & System.Net.Dns. GetHostByName(" LocalHost").Hos tName &
vbCrLf & _
"User Name: " & System.Environm ent.UserName)

how can I display my IP address?

Also, what is the difference between a DNS Name and a NetBIOS name?


May 23 '06 #5
cj
I don't get an IP address. That gives me:

? System.Net.Dns. Resolve(System. Net.Dns.GetHost Name)
{System.Net.IPH ostEntry}
AddressList: {Length=1}
Aliases: {Length=0}
HostName: "CJ"

I'm using VS2003 if that changes things. I should have mentioned it.

Peter wrote:
Sam,

Maybe we should use System.Net.Dns. Resolve(System. Net.Dns.GetHost Name)
instead of
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName).

Peter

"Sam Malone" <th************ @hotmail.com>
wrote:#7******* *******@TK2MSFT NGP02.phx.gbl.. .
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function


May 23 '06 #6
Could be. It works "as is" for me in VS2005
"cj" <cj@nospam.nosp am> wrote in message
news:uB******** ******@TK2MSFTN GP04.phx.gbl...
GetHostEntry is not a member of System.Net.Dns

Perhaps it's because I'm using VS2003?

Sam Malone wrote:
Public Function Get_LocalIPAddr ess() As String

Dim h As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(Sy stem.Net.Dns.Ge tHostName)

'return any string found

Get_LocalIPAddr ess = CType(h.Address List.GetValue(0 ),
System.Net.IPAd dress).ToString

End Function
"cj" <cj@nospam.nosp am> wrote in message
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
I can get my DNS Name, Machine Name and User Name like

MessageBox.Show ("NetBIOS Name: " & System.Environm ent.MachineName &
vbCrLf & _
"DNS Name: " & System.Net.Dns. GetHostByName(" LocalHost").Hos tName &
vbCrLf & _
"User Name: " & System.Environm ent.UserName)

how can I display my IP address?

Also, what is the difference between a DNS Name and a NetBIOS name?


May 23 '06 #7
Hi cj,

Thanks for your feedback!

You can get the IP address like this:
private void button1_Click(o bject sender, System.EventArg s e)
{
IPHostEntry hostInfo = Dns.GetHostByNa me("host name");
byte[] ipaddr=hostInfo .AddressList[0].GetAddressByte s();
MessageBox.Show ("IP Address:
"+ipaddr[0]+"."+ipaddr[1]+"."+ipaddr[2]+"."+ipaddr[3]+"\n");
}

This code snippet works well on my side. Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

May 24 '06 #8
Jeffrey,

I had to smile, but it is true, be aware that this is a VB Net newsgroup and
that your code can look confusing for some people searching this newsgroup.

Cor

""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.com> schreef in bericht
news:CD******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi cj,

Thanks for your feedback!

You can get the IP address like this:
private void button1_Click(o bject sender, System.EventArg s e)
{
IPHostEntry hostInfo = Dns.GetHostByNa me("host name");
byte[] ipaddr=hostInfo .AddressList[0].GetAddressByte s();
MessageBox.Show ("IP Address:
"+ipaddr[0]+"."+ipaddr[1]+"."+ipaddr[2]+"."+ipaddr[3]+"\n");
}

This code snippet works well on my side. Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

May 24 '06 #9
Oh, yes, it seems that I mislooked the queue name :-(

Anyway, a C# to VB.net converter can help here:
http://www.developerfusion.co.uk/uti...sharptovb.aspx

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
May 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
28316
by: Shinin | last post by:
I am trying to set up a mailto: link so that the actual address that the email is being sent to is obscured and replaced by a name. For example, I have <a href="mailto:jschmoe@abc.com">Joe Schmoe</a>. When this link is clicked, an email window appears in the clicker's email client where the To: field is jschmoe@abc.com. What I want to have...
23
3133
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H 0H0</p> <p class="Telephone">Telephone: 555-1234 </p> <p class="Fax">Fax: 555-4321</p> </div>
10
13423
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group related to checkboxes. Thanks!!!
19
6860
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the...
4
2093
by: MRBEATZ | last post by:
I'm new to this group on here, but I wanted to know if anyone knows how to display an IP address using javascript. Thanks in advance. Randy
5
3923
by: Kevin Newman | last post by:
Does anyone know of any application (AJAX or other) that will display the appropriate address for for the selected (or detected) country? If not, does anyone know where I can find a list or database of address formats, so that I can make a collection of xml files (or php and/or javascript classes) that represent the address format for each...
2
2189
by: HarisHohkl | last post by:
Hi, I've this function in a class to update the total value.but when i try to remove the these row highlight in Bold it crash, what should i do???? void display_total_value() { double value; double totalvalue=0; int r, c; setcolor (11); for( r=0; r<row; r++ )
4
2157
by: fiversen | last post by:
Hello, I have a site for the collegue with a football winning game. ...fussball.html there I redirect the user to an cgi-page ../f11.cgi
14
2959
by: Gordon Allott | last post by:
Hello :) The result of various incompatibilities has left me needing to somehow extract the address that a null pointer is pointing to with the null pointer being exposed to python via PyCObject_FromVoidPtr the code that creates the PyCObject is as follows: tmp = PyCObject_FromVoidPtr (info.info.x11.display, NULL); PyDict_SetItemString...
5
3661
by: alexandrus | last post by:
Hello, I have a problem. I have a email stored in database in fields (e.g. AddressLine1, Postal Code, Zip .. e.t.c.) I need a solution to display address to user in selected country format. It does't matter online service or offline dll. It doesn't matter free or paid service. Please, help
0
7486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.