Ready to get started with anonymous questions today? It's easy! Learn more.
Private Sub BackgroundWorker4_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker4.DoWork ifonline1 = 0 counter = 0 InitializeTimer() MsgBox("Attempting to power on " & strcomputer) Do Until ifonline1 = 1 Or counter >= 5 On Error Resume Next Dim Ping As New Net.NetworkInformation.Ping Dim PingOptions As New Net.NetworkInformation.PingOptions PingOptions.Ttl = 64 Dim PingReply As Net.NetworkInformation.PingReply = Ping.Send(strcomputer, 200) If PingReply.Status = Net.NetworkInformation.IPStatus.Success Then ifonline1 = 1 flag4 = "ON" Else ifonline1 = 0 flag4 = "OFF" End If Loop MsgBox(flag4) If ifonline1 = 1 Then Dim Host As Net.IPHostEntry = Net.Dns.GetHostEntry(strcomputer) Dim firstaddress As Net.IPAddress = Host.AddressList(0) ip = firstaddress.ToString End If flag1 = pc3 flag2 = ip flag3 = rownum worker.ReportProgress(prog1) Next End Sub Private Sub InitializeTimer() ' Run this procedure in an appropriate event. counter = 0 Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If counter >= 6 Then ' Exit loop code. Timer1.Enabled = False counter = 0 Else 'MsgBox(counter) ' Run your procedure here. ' Increment counter. counter = counter + 1 End If End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.