F FFMan Member Licensed User Longtime User Sep 20, 2011 #1 this doesn't compile Astreams.Write(13) as the compiler assumes the 13 is a double and therefore doesn't match the required byte argument type. In VB it would type convert, in other languages you could put say 13% to indicate an integer. Whats the android equivelent please ?
this doesn't compile Astreams.Write(13) as the compiler assumes the 13 is a double and therefore doesn't match the required byte argument type. In VB it would type convert, in other languages you could put say 13% to indicate an integer. Whats the android equivelent please ?
agraham Expert Licensed User Longtime User Sep 20, 2011 #2 Basic4android will usually coerce types automatically. Your problem is a deeper one in that AsyncStreams.Write expects a byte array and not a single value as you are attempting to pass. Upvote 0
Basic4android will usually coerce types automatically. Your problem is a deeper one in that AsyncStreams.Write expects a byte array and not a single value as you are attempting to pass.
F FFMan Member Licensed User Longtime User Sep 20, 2011 #3 ok i understand. so if i write strBytes(1)=13 then that will work, but given that i have in the lines before put a longer string into strByes() how can I tell astreams.write where in the array to stop sending. How does it know how long the string is as i have dimensioned it to 99 elements ? Indeed if I have strBytes = conv.StringToBytes(DateTime.Now,"UTF8") Astreams.Write(strBytes) how is the end marked as I don't think all 99 bytes are being sent each time, unless the rest contains nulls which i can't see in the display label and all 99 are being sent. If thats the case can i dimension the array to size every pass ? thanks Upvote 0
ok i understand. so if i write strBytes(1)=13 then that will work, but given that i have in the lines before put a longer string into strByes() how can I tell astreams.write where in the array to stop sending. How does it know how long the string is as i have dimensioned it to 99 elements ? Indeed if I have strBytes = conv.StringToBytes(DateTime.Now,"UTF8") Astreams.Write(strBytes) how is the end marked as I don't think all 99 bytes are being sent each time, unless the rest contains nulls which i can't see in the display label and all 99 are being sent. If thats the case can i dimension the array to size every pass ? thanks
rbsoft Active Member Licensed User Longtime User Sep 21, 2011 #4 Learned this from Erel: Code: Copy Astreams.Write(Array As Byte(13)) Rolf Upvote 0
agraham Expert Licensed User Longtime User Sep 21, 2011 #5 FFMan said: How does it know how long the string is as i have dimensioned it to 99 elements Click to expand... Code: Copy Dim strBytes(99) as Byte ' strBytes holds a reference (pointer) to an array(99) strBytes = conv.StringToBytes(DateTime.Now,"UTF8") ' strBytes now points to a new array of whatever length ' the previous array will be garbage collected Upvote 0
FFMan said: How does it know how long the string is as i have dimensioned it to 99 elements Click to expand... Code: Copy Dim strBytes(99) as Byte ' strBytes holds a reference (pointer) to an array(99) strBytes = conv.StringToBytes(DateTime.Now,"UTF8") ' strBytes now points to a new array of whatever length ' the previous array will be garbage collected