Gopher2011
Well-known member
Hi, I have 1 string of 12 numbers separated by a ',' "11.11,22.22,33.33" etc coming in my serial port. One number has so far been 5339, but now its changed to 533d, which causes problems, for reasons I am still trying to work out.
The top numbers are all real numbers ie 0.000 or 00.00 or 000.0, whereas the bottom 3 numbers are Hex FFFFF but just happen to show decimal numbers by 'good luck'.
When the Hex numbers show 'decimals' they convert/whatever ok, but showing abcdef hex they trip it up.. I know its the Integer part of Word0. However I am out of ideas.
Any advice?
In the debug it looks like this:-
However value <11> has changed to 533d And debug throws an exception now..
The top numbers are all real numbers ie 0.000 or 00.00 or 000.0, whereas the bottom 3 numbers are Hex FFFFF but just happen to show decimal numbers by 'good luck'.
When the Hex numbers show 'decimals' they convert/whatever ok, but showing abcdef hex they trip it up.. I know its the Integer part of Word0. However I am out of ideas.
Any advice?
VB.NET:
Public Number_01 As Integer
.....
Public Number_09 As Integer
Public Word0 As Integer
Public Word1 As Integer
Public Word2 As Integer
Private Sub Sort()
Dim i As Integer
Dim SortedRxText() As String
SortedRxText = txt_Latest_ComsIn.Text.Split(",")
For i = 0 To UBound(SortedRxText)
Debug.WriteLine(i & " " & SortedRxText(i))
If NxtExptData4 = "l" Then
Select Case i
Case i : Anal_RAW(i) = Convert.ToDouble(SortedRxText(i))
End Select
'Wait till all the data is read before copying it.
If i = 13 Then
Number_01 = CDbl(Analg_RAW(1))
Number_02 = CDbl(Analg_RAW(2))
Number_03 = CDbl(Analg_RAW(3))
Number_04 = CDbl(Analg_RAW(4))
Number_05 = CDbl(Analg_RAW(5))
Number_06 = CDbl(Analg_RAW(6))
Number_07 = CDbl(Analg_RAW(7))
Number_08 = CDbl(Analg_RAW(8))
Number_09 = CDbl(Analg_RAW(9))
Word0 = "&H" & Analg_RAW(10)
Word1 = "&H" & Analg_RAW(11)
Word2 = "&H" & Analg_RAW(12)
End If
End If
Next i
In the debug it looks like this:-
VB.NET:
0 0000
1 -2.8
2 1010
3 0.0
4 0166
5 21.3
6 0153
7 373
8 1011
9 5698
10 0000
11 5339
However value <11> has changed to 533d And debug throws an exception now..
VB.NET:
0 0000
1 -2.8
2 1010
...
10 0000
11 533d
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll