Reputation: 49
Well in c# it would look like:
Byte[] ulaznipodaci = new Byte[] { 0x08, 0x3F, 0x20, 0x03, 0x00, 0x00, 0x05, 0x00 };
sck.Send(ulaznipodaci);
I need this kind of code in vb6. I tried:
Dim ulaznipodaci() As Byte
ulaznipodaci = Array(&H8, &H3F, &H20, &H3, &H0, &H0, &H5, &H0)
Winsock2.SendData ulaznipodaci
But this code gives me an error on the line ulaznipodaci = Array(&H8, &H3F, &H20, &H3, &H0, &H0, &H5, &H0)
saying: Run time error '13': Type mismatch.
I searched google but couldn't find anything. Please help, I'm kinda new in vb6. Thanks in advance.
Upvotes: 0
Views: 764
Reputation: 55
.. or for example store in a string and then read in cycle
St="&H8, &H3F, &H20, &H3, &H0, &H0, &H5, &H0"
for i = 1 to N
pos = (i-1)*6 ' poition & ulaznipodaci(i)=mid(St,pos,4) ' we do not need "," and a space
next
Upvotes: 0
Reputation: 16368
In VB6, you have to define your array's bounds and then populate each item separately:
Dim ulaznipodaci(7) As Byte
'// VB6 array is zero based unless you specify lower to upper bounds
ulaznipodaci(0) = &H8
ulaznipodaci(1) = &H3F
ulaznipodaci(2) = &H20
ulaznipodaci(3) = &H3
ulaznipodaci(4) = &H0
ulaznipodaci(5) = &H0
ulaznipodaci(6) = &H5
ulaznipodaci(7) = &H0
If, later you need to add more items:
ReDim Preserve ulaznipodaci(8)
ulaznipodaci(8) = &H0
Upvotes: 1