Second Project LanIM

thexero

Active member
Joined
Jan 27, 2007
Messages
26
Programming Experience
3-5
hi

i have been trying to learn vb.net for about a year now

i have created my own program in vb.net, a simple calculator but i am on a home network and my parents want to be able to send messages to each other in the network, so i said i will make one. i am hoping to just use the windows messenger service so my family don't have to keep the application open all the time to recieve messages.

originally i thought about how i was going to do this. i have a combo box and i want it to be able to list the netorked computers names, so i wanted my program to create a batch file with so i would open command prompt and do 'net view' so i could get the computer names. i have another combo box and i want to be able to select a username to send this message to using the same technique. i don't know how to get my application to create these batch files

i have tried to start on this but my code hasn't really begun

PublicClass MainWindow
PrivateSub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
'Closes the application
End
EndSub
PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
'Attepts to get computer names
File.Open("C:\LanIM.bat")
Dim Message As String
Message = (C:/LanIM.bat)




EndSub
EndClass
my syntax for the end is a bit wrong lol could i have some help with this
thanx
 
If it's a home network, the hostnames will probably not change much, if at all. You could just find out what the hostnames are and do this. This will add the hosts to a listbox if they are on the network.
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.Network.Ping([/SIZE][SIZE=2][COLOR=#800000]"one of your hostnames"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]ListBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"one of your hostnames"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

Also, two things. You're most likely going to have to have a program up and running at all times on both ends to send and receive messages. And, unless you just want to do this for the experience, you could just use Microsoft Net Meeting to communicate between computers. Net Meeting will let you share your desktop, draw together on a whiteboard, and share files.
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.Network.Ping([/SIZE][SIZE=2][COLOR=#800000]"one of your hostnames"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]ListBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"one of your hostnames"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

thanks for your help

after the second combox1 i put else as if that host is not returned i get errors lol

what should i put for else

thanx

also, how can i stop users from writing stuff in the combobox?
 
Last edited:
Maybe you could put the ping event in a "try..catch" block and show a messagebox saying that the user isn't online. Maybe someone else will have a better answer. It seems like there should be a better way to handle not getting a ping reply. As for not allowing the combobox text to be edited, you can thank JohnH for this post :D :

http://www.vbdotnetforums.com/showthread.php?t=16882
 
Not to hijack this thread, but this is actually relevant to something I'm doing now. Does anyone else know a way to return all of the hostnames that are currently on the network? I'd like to have them in a listbox so that I can select one to remotely view their running processes and performance. Thanks.
 
Back
Top