D dmtulsa Member Licensed User Longtime User Dec 11, 2012 #1 How would I create an array of bytes form string inputs. I posted this this before but just for 1 short. Now I need to make an array. Example the PIC mcu is looking for 4 words/shorts to to be sent to it. This is wrong as it wont compile Code: Copy Dim BC As ByteConverter Dim dm As Short = "1" 'convert the string to short Dim Cspd As Short = txtCycleSpeed.Text 'convert the string to short Dim Rspd As Short = txtRelaySpeed.Text 'convert the string to short Dim Ccnt As Short = txtCycleCnt.Text 'convert the string to short Dim PicWrd(3) As Byte PicWrd(0) = BC.ShortsToBytes(Array As Short(dm)) PicWrd(1) = BC.ShortsToBytes(Array As Short(Cspd)) PicWrd(2) = BC.ShortsToBytes(Array As Short(Rspd)) PicWrd(3) = BC.ShortsToBytes(Array As Short(Ccnt)) AStream.Write(PicWrd) Thank you
How would I create an array of bytes form string inputs. I posted this this before but just for 1 short. Now I need to make an array. Example the PIC mcu is looking for 4 words/shorts to to be sent to it. This is wrong as it wont compile Code: Copy Dim BC As ByteConverter Dim dm As Short = "1" 'convert the string to short Dim Cspd As Short = txtCycleSpeed.Text 'convert the string to short Dim Rspd As Short = txtRelaySpeed.Text 'convert the string to short Dim Ccnt As Short = txtCycleCnt.Text 'convert the string to short Dim PicWrd(3) As Byte PicWrd(0) = BC.ShortsToBytes(Array As Short(dm)) PicWrd(1) = BC.ShortsToBytes(Array As Short(Cspd)) PicWrd(2) = BC.ShortsToBytes(Array As Short(Rspd)) PicWrd(3) = BC.ShortsToBytes(Array As Short(Ccnt)) AStream.Write(PicWrd) Thank you
Erel B4X founder Staff member Licensed User Longtime User Dec 11, 2012 #2 Code: Copy Dim PicWrd() As Byte PicWrd = BC.ShortsToBytes(Array As Short(dm, Cspd, Rspd, Ccnt)) AStream.Write(PicWrd) Upvote 0
Code: Copy Dim PicWrd() As Byte PicWrd = BC.ShortsToBytes(Array As Short(dm, Cspd, Rspd, Ccnt)) AStream.Write(PicWrd)
D dmtulsa Member Licensed User Longtime User Dec 11, 2012 #3 Thanks very much. I'm starting to get the feel of how thing work together. Doug Upvote 0