Tuesday, July 28, 2009

Help with VB program?

Ok here's what i did. I made a form, put 33 pictureboxes on it, and named them the Computer Names of 33 machines on the network. Next I added thoses pictureboxes to an array as follows:





Dim picArray(32) As PictureBox 'array of pictureboxes


picArray(0) = Station01


picArray(1) = Station02


picArray(2) = Station03


....


picArray(32) = Station33





then what i did was looped through the array, pinging the computer name.





For i = 0 To picArray.Length - 1


picArray(i).SizeMode = PictureBoxSizeMode.StretchImage





Try


If My.Computer.Network.Ping(picArray(i).Nam... 20) Then





picArray(i).ImageLocation = "C:\pc\good.bmp"


End If


Catch ex As Exception


picArray(i).ImageLocation = "C:\pc\bad.bmp"


End Try





Next





the code works, but its slow. Is there anyway to speed it up

Help with VB program?
You are loading the image from the disk 33 times.





You will cut a few seconds by loading good.bmp %26amp; bad.bmp to an imagelist at the start of the program and then setting the image from the imagelist inside the bmp.





Since you are using a ping which is a network function it is bound to be a bit slow. Consider putting each ping on a seperate thread. That will allow the program to move forward without waiting for the response.
Reply:if want animation information


http://entertainmennnt.blogspot.com/
Reply:1. You could put the images (good.bmp, bad.bmp) in a resource file as part of your application. The pics will be embedded and that might save you time.





2. Instead of using picture boxes, draw the images directly using the Graphics object. (graphics.DrawImage()...)





That might speed things up a bit. Otherwise, it's probably network issue, which is probably out of your control.


No comments:

Post a Comment