Beginners Guide To Getting IPaddress Programatically
Note: As always, Open VB.net and follow along, if you just grab the sample, You will never learn anything.
Lets begin by creating a "New Project" I called my project "GetIP" , However you can call yours anything you like.
[IMG]http://i111.photobucke*****m/albums/n121/golmor/newproj1.jpg[/IMG]
Add one "'Label" and one "Button" to the form
Note: Text, Font , Style and placement have no relevance, Design it anyway you like
You should have a form that looks similar to this.
[IMG]http://i111.photobucke*****m/albums/n121/golmor/mpghip.jpg[/IMG]
Now you need to add the reference system.net
(you can achieve this by clicking project then add reference, in your toolbar)
Scroll down and click system.net, Finally...Click Ok
(You should see this)
[IMG]http://i111.photobucke*****m/albums/n121/golmor/sysnet.jpg[/IMG]
Tip: VS (Vb.net in this case) Hotkey -- F7 -- Enters the coding window
At this point you need to open the codeing window , You can achieve this numerous ways, but the fastest is with the hot key "F7"
Now type "Imports System.Net" above public class *Form Name*
("General" Area")
Now add this code inside the button click event (if you don't know how to do this from the code window, go back to the designer and double click the button)
No offense to the copy and pasters, but it's time you started learning, so instead of proving the code in a copy/paste friendly manner, I am adding a screenshot, If you would like to use this, your going to have to type it out...sorry leechers, it's for your own good
Note: I suggest anyone writing a tutorial adopts this method in order to truley help those who seek help, it will also weed out C&P.
Obviously if you are offering support it will be better to use the [.code] Tags, but otherwise I suggest screenshots.
[IMG]http://i111.photobucke*****m/albums/n121/golmor/code34.jpg[/IMG]
Now press F5 (debug) and test your project.
You should get something like this as a result (on button click)
[IMG]http://i111.photobucke*****m/albums/n121/golmor/form2.png[/IMG]
Hope this helps
(Part 2, Intermediate way of retrieving your "Real" IpAddress)