图片盒断断续续

时间:2018-07-03 10:55:52

标签: vb.net picturebox

大家好,我有backgroundworker来更新正在检查ping的图片框,并根据响应时间选择6张不同的图片中的1张以填充该框...有点像信号条图片。我将错误图像设置为看起来像零条的图片,但由于某种原因,它决定在哪里显示红色X的错误图片,甚至在调试时也可以根据ping响应看到它。确实告诉它从资源中加载适当的图片...但是它不会改变它。后台工作人员由设置为1000 ms的计时器触发,但已将其提高到5秒,仍然出现错误...如果我能弄清楚大声笑的话,要包括代码和图像

Public Sub CheckNetwork()
    Dim Result As Net.NetworkInformation.PingReply
    Dim SendPing As New Net.NetworkInformation.Ping
    Dim ResponseTime As Long '<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Try
        Result = SendPing.Send("8.8.8.8")
        ResponseTime = Result.RoundtripTime
        If Result.Status = Net.NetworkInformation.IPStatus.Success Then
            If ResponseTime.ToString > 0 And ResponseTime.ToString < 35 Then
                pbInternetStatus.Load("resources\signal5.png")
            ElseIf ResponseTime.ToString >= 35 And ResponseTime.ToString < 45 Then
                pbInternetStatus.Load("resources\signal4.png")
            ElseIf ResponseTime.ToString >= 45 And ResponseTime.ToString < 65 Then
                pbInternetStatus.Load("resources\signal3.png")
            ElseIf ResponseTime.ToString >= 65 And ResponseTime.ToString < 85 Then
                pbInternetStatus.Load("resources\signal2.png")
            ElseIf ResponseTime.ToString >= 85 Then
                pbInternetStatus.Load("resources\signal1.png")
            End If
        Else
            pbInternetStatus.Load("resources\signal0.png")
        End If
    Catch ex As Exception
    End Try
End Sub

Private Sub bgwCheckNetwork_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles bgwCheckNetwork.DoWork
    CheckNetwork()
End Sub

Private Sub tmrNetCheck_Tick(sender As Object, e As EventArgs) Handles tmrNetCheck.Tick
    If Not bgwCheckNetwork.IsBusy Then
        bgwCheckNetwork.RunWorkerAsync()
        bgwCheckNetwork.Dispose()
    End If
End Sub

图片没有任何错误:

Without the error

显示错误的图片:

With the error

0 个答案:

没有答案