Using Binary data

Active 2D-Barcode Control can handle binary data, but special considerations arise when that data will contain ASCII 0 (null) characters. The Caption property is treated as a C string – and so terminates at the first null character.

To send binary data containing ASCII 0 characters to the control one of two available Methods should be used:

SetByteStream(LPCTSTR lpstream, short nlength)

or

SetIntStream(short FAR* lpstream, short nlength)

In both cases the byte data is pointed to by the lpstream parameter, and the length of the data is specified in the nlength parameter.

A Visual Basic routine for using binary data as a string of specified length is:

 

Private Sub Command1_Click()
Dim bts(1000) As Integer
x$ = String(372, vbNullChar)
n = Len(x$)

Open "data.dat" For Binary As #1 Len = 372
Get #1, , x$
Close #1

Call AdBarcode1.SetByteStream(z$, n)
Image1.Picture = AdBarcode1.Picture

End Sub

 

An alternative routine, in which the data is encoded in a integer array is:

 

Private Sub Command1_Click()
Dim bts(1000) As Integer
x$ = String(372, vbNullChar)
n = Len(x$)

Open "data.dat" For Binary As #1 Len = 372
Get #1, , x$
Close #1

For i = 1 To n
c$ = Mid$(x$, i, 1)
If (c$ = "") Then
j = 0
Else
j = Asc(c$)
End If
bts(i) = j
Next i

Call AdBarcode1.SetIntStream(bts(1), n)
Image1.Picture = AdBarcode1.Picture

 

End Sub

 

 

More:

A Note on Metafile pictures