Invalid double?

techknight

Well-Known Member
Licensed User
Longtime User
I have this code in a subroutine in my app. And the code works fine.

B4X:
Sub NumToSeg(numval As Byte) As String
Dim Returndata As Byte
'Santech Register:
'Bit 0 = D
'Bit 1 = C
'Bit 2 = B
'Bit 3 = A
'Bit 4 = Empty
'Bit 5 = F
'Bit 6 = E
'Bit 7 = G
Select Case numval
   Case 0 
      Returndata = "6F"
   Case 1
      Returndata = "06"
   Case 2
      Returndata = "CD"
   Case 3
      Returndata = "8F"
   Case 4
      Returndata = "A6"
   Case 5
      Returndata = "AB"
   Case 6 
      Returndata = "EB"
   Case 7 
      Returndata = "0E"
   Case 8
      Returndata = "EF"
   Case 9
      Returndata = "AF"
   Case Else
      Returndata = "00"
   End Select
   Return Returndata

End Sub

Except, every once in awhile it crashes with Invalid Double "CD"
servicetxrx_numtoseg (B4A line: 475)
Returndata = "CD"
java.lang.NumberFormatException: Invalid double: "CD"

Which is the Returndata = "CD" Why is this? its not a double, its a string.
 

techknight

Well-Known Member
Licensed User
Longtime User
Nevermind, I am a jackass. The variable is a Byte, but yet I am returning a string. Whoopsie.

I know i can probably do this using some kind of a lookup function of some sorts, but eh. I digress.... the select case is simple and it works. lol.
 
Last edited:
Upvote 0
Top