F FFMan Member Licensed User Longtime User Sep 14, 2011 #1 Just trying to get to grips with B4a, though I am proficient in VB6 and ZBASIC code, the android way is a little different but i am enjoying the learning. I am converting the bluetooth serial example to use astreams as suggested as i couldn't find published complete code, just some extracts. The receive section using astreams works, and so does the send if i leave it as textwriter but i guess i should use astreams for send too for reasons stated. the problem is more with stringtobytes, this just won't compile Code: Copy Sub btnSend_Click Dim strBytes(9) As Byte If connected Then strBytes() = StringToBytes(txtSend.Text,"UTF8") Astreams.Write(strBytes()) 'TextWriter1.WriteLine(txtSend.Text) 'TextWriter1.Flush txtSend.Text = "" End If End Sub i've added the byteconverter library (though i'm, not sure if this is required as the bytestostring call in the receive routine compiles OK without this library for some reason). i'm sure i'm missing something basic here :signOops: any help much appreciated.
Just trying to get to grips with B4a, though I am proficient in VB6 and ZBASIC code, the android way is a little different but i am enjoying the learning. I am converting the bluetooth serial example to use astreams as suggested as i couldn't find published complete code, just some extracts. The receive section using astreams works, and so does the send if i leave it as textwriter but i guess i should use astreams for send too for reasons stated. the problem is more with stringtobytes, this just won't compile Code: Copy Sub btnSend_Click Dim strBytes(9) As Byte If connected Then strBytes() = StringToBytes(txtSend.Text,"UTF8") Astreams.Write(strBytes()) 'TextWriter1.WriteLine(txtSend.Text) 'TextWriter1.Flush txtSend.Text = "" End If End Sub i've added the byteconverter library (though i'm, not sure if this is required as the bytestostring call in the receive routine compiles OK without this library for some reason). i'm sure i'm missing something basic here :signOops: any help much appreciated.
agraham Expert Licensed User Longtime User Sep 15, 2011 #2 Code: Copy Dim conv As ByteConverter strBytes() = conv.StringToBytes(txtSend.Text,"UTF8") Upvote 0
F FFMan Member Licensed User Longtime User Sep 15, 2011 #3 thanks but i get Error description: Missing parameter. Occurred on line: 72 strBytes() = conv.StringToBytes(txtSend.Text,"UTF8") Word: ( the pop-up help shows only 2 parameters required. Also, out of interest why does the BytesToString in the receive routine not have to be declared and structured the same way. Is this a core function perhaps ? Upvote 0
thanks but i get Error description: Missing parameter. Occurred on line: 72 strBytes() = conv.StringToBytes(txtSend.Text,"UTF8") Word: ( the pop-up help shows only 2 parameters required. Also, out of interest why does the BytesToString in the receive routine not have to be declared and structured the same way. Is this a core function perhaps ?
agraham Expert Licensed User Longtime User Sep 15, 2011 #4 Sorry, I modified your code without looking at it closely. Remove the parentheses from the array assignment. Code: Copy strBytes[B][COLOR="Red"]()[/COLOR][/B] = conv.StringToBytes(txtSend.Text,"UTF8") BytesToString is a intrinsic language keyword. ByteConverter is an object on which you need to invoke methods. Upvote 0
Sorry, I modified your code without looking at it closely. Remove the parentheses from the array assignment. Code: Copy strBytes[B][COLOR="Red"]()[/COLOR][/B] = conv.StringToBytes(txtSend.Text,"UTF8") BytesToString is a intrinsic language keyword. ByteConverter is an object on which you need to invoke methods.