Android Question Give me a empty string ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
PC side give me string "#0000011223*". Why I always get a null string(s1) from BytesToString but buffer() have data inside ?

Sub AStream_NewData(buffer() As Byte)
Dim s1 As String

If buffer.Length>0 Then
s1 = BytesToString(buffer, 0, buffer.Length, "UTF8")
bt.Rxbf = bt.Rxbf + s1
End If
End Sub
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
bt.Rxbf = bt.Rxbf + s1 ==> java.lang.NumberFormatException: Invalid double: "" ?????
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
Why following code is ok !


If buffer.Length>0 Then
s1 = BytesToString(buffer, 0, buffer.Length, "UTF8")

If s1.Length > 0 Then
bt.Rxbf = s1
End If
End If
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Type BtPacket (Cmd As Int, Step As Int, Interval As Int,Txbf As String, Rxbf As String)
Dim bt As BtPacket
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
bt.Rxbf seems to be an double. and you cannot add a string to a double

What you want is concat the both strings. You have to use & instead of +
 
Upvote 0
Top