I'm using ByteConverter to convert byte to hex, but get the error when debug.
I want to show a hex code one by one.
below is error msg:
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=Byte,Rank=0, RemoteObject=True} to: {Type=Byte,Rank=1, RemoteObject=True}
Occurred on line: 53
msg=conv.HexFromBytes(Buffer(i))
Word: )
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim socket1 As Socket
Dim AStreams As AsyncStreams
Dim conv As ByteConverter
End Sub
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
socket1.Initialize("socket1")
socket1.Connect("192.168.0.153",4001,20000)
End Sub
B4X:
Sub socket1_connected(Successful As Boolean)
If Successful = False Then
Msgbox(LastException.Message, "Error connecting")
socket1.Close
Activity.Finish
Return
Else
AStreams.Initialize(socket1.InputStream, socket1.OutputStream, "AStreams")
ToastMessageShow("Connected", True)
End If
End Sub
B4X:
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
For i = 0 To Buffer.Length - 1
msg=conv.HexFromBytes(Buffer(i))
ToastMessageShow(msg,False)
Next
End Sub
I want to show a hex code one by one.
below is error msg:
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=Byte,Rank=0, RemoteObject=True} to: {Type=Byte,Rank=1, RemoteObject=True}
Occurred on line: 53
msg=conv.HexFromBytes(Buffer(i))
Word: )
Last edited: