vb.net - 为什么将数据移动到文本字段时,索引超出了数组的范围
问题描述
这是我的代码 - 本部分正在查看来自 NMEA GPS 设备的消息
Try
degreeString = Words(3).Substring(0, 2)
LatDD = CDec(degreeString)
MinuteString = (Words(3).Substring(2, 8))
LatDM = CDec(CInt(MinuteString) / 60)
LatDecimalDegrees = LatDD + LatDM
If Words(4) = "S" Then
LatDecimalDegrees *= -1
End If
Catch ex As Exception
errorCount = errorCount + 1
ErrorDisplay.Clear()
ErrorDisplay.Text = ToString(errorCount)
GPS_WordOK = False
Exit Function
End Try code here`Try
degreeString = Words(3).Substring(0, 2)
LatDD = CDec(degreeString)
MinuteString = (Words(3).Substring(2, 8))
LatDM = CDec(CInt(MinuteString) / 60)
LatDecimalDegrees = LatDD + LatDM
If Words(4) = "S" Then
LatDecimalDegrees *= -1
End If
Catch ex As Exception
errorCount = errorCount + 1
ErrorDisplay.Clear()
ErrorDisplay.Text = ToString(errorCount)
GPS_WordOK = False
Exit Function
End Try
异常处理中在这一行抛出错误
ErrorDisplay.Text = ToString(errorCount)
error_count 的值为 49
我看不到失败行中隐含数组的位置
导致进入异常处理程序的错误由语句抛出
LatDM = CDec(CInt(MinuteString) / 60)
字符串值为 41*68028
我相信线路上的一些噪音导致小数被读取为星号并且除法失败。此错误恢复在 24 小时内成功进行了 48 次。
解决方案
使用任一
ErrorDisplay.Text = errorCount.ToString
或者
ErrorDisplay.Text = CStr(errorCount)
推荐阅读
- angular - 角度分量内的角度分量?`
` - python - 没有名为“袜子”的模块
- xamarin - 来自本地 IP 的图像源未在 Xamarin.Forms Image 或 FFImage 中显示
- javascript - InvalidValueError: setIcon: not a string; and not an instance of PinView; and no url property; and no path property
- javascript - Frida - 转储/检查对象的功能
- javascript - Why does this mongodb controller pass undefined back to route?
- reactjs - trying to use a function that return a button component but nothing get rendered
- javascript - Functions on header not working - AngularJs & Javascript
- r - 如何在 R 或 Python 中对多列进行延迟,如下所示
- javascript - 在javascript中组合2个函数的输出