M medsport2012 Member Licensed User Longtime User Jul 22, 2019 #1 Please explain how to convert string (receiving from serial) to long
Erel B4X founder Staff member Licensed User Longtime User Jul 22, 2019 #2 Code: Dim number As Long = SomeString Upvote 0
E emexes Expert Licensed User Longtime User Jul 22, 2019 #3 i/ never hurts to check first that the string is actually a number, eg: Code: If IsNumber(SomeString) Then Dim Number As Long = SomeString Else Log("Number? That's not a number...") Dim Number As Long = 999999999999999999 'that's a number ;-) End If or: Code: Try Dim Number As Long = SomeString Catch Log("Nice try, no cigar") End Try ii/ is the string readable text, or is it a packet of data of raw bytes ie in binary format? edit: sadly, the hyperlink on the that's a number comment got lost in the code block. Upvote 0
i/ never hurts to check first that the string is actually a number, eg: Code: If IsNumber(SomeString) Then Dim Number As Long = SomeString Else Log("Number? That's not a number...") Dim Number As Long = 999999999999999999 'that's a number ;-) End If or: Code: Try Dim Number As Long = SomeString Catch Log("Nice try, no cigar") End Try ii/ is the string readable text, or is it a packet of data of raw bytes ie in binary format? edit: sadly, the hyperlink on the that's a number comment got lost in the code block.