Groups | Blog | Home
all groups > vb.net > february 2008 >

vb.net : how to declare a button


kimiraikkonen
2/6/2008 2:22:35 AM
[quoted text, click to view]

Couldn't estimate what you exactly done but if declare new button
before you declare "pingwork" function sub. Also it would be more
helpful to paste error message. I simulated your code you get the
error:

"WorkName' is already declared as a parameter of this method." then
what you must do is to declare WorkName button just before "pingwork"
Tony WONG
2/6/2008 1:18:13 PM
i write the following program to detect workstation ON or OFF

but i do not know how to paste the parameter from Timer1_Tick to pingwork

it comes to error in these lines -- WorkName
Private Sub pingwork(ByVal WorkIP, ByVal WorkName)
Dim WorkName As New Button

Could you teach me to do it? Thanks a lot.



************************************************
Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
pingwork("Work01", "Work01")
pingwork("Work02", "Work02")
End Sub

Private Sub pingwork(ByVal WorkIP, ByVal WorkName)
Dim WorkName As New Button
Controls.Add(WorkName)
WorkName.Text = WorkIP

If My.Computer.Network.Ping(WorkIP) Then
WorkName.BackColor = Color.Gold
WorkName.ForeColor = Color.Black
Else
WorkName.BackColor = Color.Black
WorkName.ForeColor = Color.White
End If
WorkName.Refresh()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
End Class

AddThis Social Bookmark Button