Introdution:
hi there, im new to this forum so please be nice
I've used the search option but i can't find what i am looking for, i have also tryed to google it but i still can't find it
The problem:
I am trying to get into Using V.B, i have downloaded "ms visual basics 2005 express edition" from the microsoft website.
in college we have been set a task to code something in V.B, i chose to "find your i.p".
i've ranted many books but they dont really show me what i need to do, im guessing its quite a simple code, all i want it to do is display an I.P (i know you can go to !www.whatismyip.com".)
!! i would like a code to simpley go into command propt and type "ipconfig" and then the results would show up on the command prompt window !!
please help,
Sorry if its stupidly easy or something , im a noob to VB lol
Last edited by scottaii; Jan 17th, 2007 at 10:07 AM.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Shell is an API that alloows you to run an external (to the VB program that's using it) program. So you could shell IPConfig, send its output to a text file, then input and parse the text to find "IP Address:" and the numbers that follow it are the IP.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
i have created a "button" and i insert the code
__________________________________________________________
Dim hostName As String = System.Net.Dns.GetHostName()
Dim ipaddress As String = System.Net.Dns.GetHostByName(hostName).AddressList(0).ToString
MessageBox.Show("My Local IP Address is: " & ipaddress)
MessageBox.Show("My Hostname is: " & hostName)
___________________________________________________________
i press "play" and it displays the .exe, it then comes with an error massage saying "compile error", "sytax error" and hightlights the 1st part of the code in red
Dim hostName As String = System.Net.Dns.GetHostName()
Dim ipaddress As String = System.Net.Dns.GetHostByName(hostName).AddressList(0).ToString
VB 2005 (all editions) are VB.Net, and VB6 is "Classic VB".
Despite them both having Visual Basic in their name, they are completely different languages. Code that works in one is very unlikely to work in the other - and your code is a good example of that.
The problem:
I am trying to get into Using V.B, i have downloaded "ms visual basics 2005 express edition" from the microsoft website.
This is NOT VB6.^^
If you tell people your using vb2005 you will receive code specific to that version.
Anyway, heres how to do it in vb6, open a new project, go to project>componants in the menubar, then scroll down the list and select and check Microsoft Internet Transfer Control, then click OK, drag an Inet onto the form from the toolbox, and put this code in a button:
VB Code:
MsgBox "Your IP is: " & Inet1.OpenURL("http://www.whatismyip.org")
After you have added the INet to the form, add a button to the form, then double click the button, and add the code:
VB Code:
MsgBox "Your IP is: " & Inet1.OpenURL("http://www.whatismyip.org")
The code must go in the Buttons click event if you want it to work when you press the button.
The problem you had is you put the code in the Inets StateChanged event, the code needs to go somewhere where you can trigger it for example a button_click or form_load