Private Sub Ping1()
Dim Result As String
While Annulation = False
Rep(0) = Ping.Send(TextBox1.Text)
If Rep(0).Status = 0 Then
If Rep(0).RoundtripTime = 0 Then
Result = String.Format("Réponse de " & TextBox1.Text & " : temps < 1 ms" & Chr(10))
Else
Result = String.Format("Réponse de " & TextBox1.Text & " : temps = " & Rep(0).RoundtripTime & " ms" & Chr(10))
End If
Me.AffichagePing1(Result)
Else
Me.AffichagePing1("Temps de réponse dépassé à " & Date.Now.ToLongTimeString & Chr(10))
End If
Thread.Sleep(200)
End While
End Sub
Private Sub AffichagePing1(ByVal [text] As String)
If Me.RichTextBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf AffichagePing1)
If text.Contains("dépassé") Then
Me.Invoke(Sub() RichTextBox1.SelectionColor = Color.Red)
Me.Invoke(Sub() RichTextBox1.AppendText(text))
Me.Invoke(Sub() RichTextBox3.Text = RichTextBox3.Text + 1)
Else
Me.Invoke(Sub() RichTextBox1.SelectionColor = Color.Black)
Me.Invoke(Sub() RichTextBox1.AppendText(text))
Me.Invoke(Sub() RichTextBox2.Text = RichTextBox2.Text + 1)
End If
'Force la RichTextBox à être toujours en bas
Me.Invoke(Sub() RichTextBox1.ScrollToCaret())
Else
Me.RichTextBox1.AppendText([text])
End If
End Sub
If (Ping.Send(TextBox2.Text)).Status = 0 Then
If (Ping.Send(TextBox1.Text)).Status = 0 Then
If Me.RichTextBox1.InvokeRequired Then ... If text.Contains("dépassé") Then ... Else
If InvokeRequired Then Invoke MaSub Return Else ... Code End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionIf InvokeRequired Then
Invoke MaSub
Return
Else
... Code
End If
Private Sub AffichagePing1(ByVal [text] As String) If Me.RichTextBox1.InvokeRequired Then Dim d As New SetTextCallback(AddressOf AffichagePing1) If text.Contains("dépassé") Then Me.Invoke(Sub() RichTextBox1.SelectionColor = Color.Red) Me.Invoke(Sub() RichTextBox1.AppendText(text)) Me.Invoke(Sub() RichTextBox3.Text = RichTextBox3.Text + 1) Else Me.Invoke(Sub() RichTextBox1.SelectionColor = Color.Black) Me.Invoke(Sub() RichTextBox1.AppendText(text)) Me.Invoke(Sub() RichTextBox2.Text = RichTextBox2.Text + 1) End If 'Force la RichTextBox à être toujours en bas Me.Invoke(Sub() RichTextBox1.ScrollToCaret()) Else Me.RichTextBox1.AppendText([text]) End If End Sub
Private Sub AffichagePing1(ByVal pText As String) If Me.RichTextBox1.InvokeRequired Then Me.Invoke(Sub() AffichagePing1(pText) Else If pText.Contains("dépassé") Then RichTextBox1.SelectionColor = Color.Red RichTextBox1.AppendText(text) RichTextBox3.Text = RichTextBox3.Text + 1 Else RichTextBox1.SelectionColor = Color.Black RichTextBox1.AppendText(text) RichTextBox2.Text = RichTextBox2.Text + 1 End If 'Force la RichTextBox à être toujours en bas RichTextBox1.ScrollToCaret() RichTextBox1.AppendText(pText) End If End Sub