Android Question how to convert string to long (integer)

Discussion in 'Android Questions' started by medsport2012, Jul 22, 2019.

  1. medsport2012

    medsport2012 New Member Licensed User

    Please explain how to convert string (receiving from serial) to long
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim number As Long = SomeString
     
    medsport2012 likes this.
  3. emexes

    emexes Well-Known Member Licensed User

    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.
     
    medsport2012 and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice