Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending a byte array to a printer/Basic to vb.net help

Status
Not open for further replies.

jcisco2

Programmer
Apr 13, 2004
102
US
I am having a problem reading in a pcx file, and sending it's binary data to a printer. I have a printer class that takes in a string with no problems. but i am having a problem converting the image here is what i need to accomplish.
"to send the data in binary format, the software must convert the data into binary format before transmitting it to the printer. Using the BASIC programming language this can be done by notation "CHR$(&HC0) which sends the hexidecimal value of C0 as binary data (11000000)

Key to example
v0100 is the vert pos
h0100 is the hor pos
GP is the type of command being sent
006006 is the bytes in the file i'm using data.Length to get this number when sending my data

BASIC EXAMPLE:
CLS
OPEN "COM2:9600, N,8,1,CS,DS" FOR OUTPUT AS #1
E$ = chr(27)
PRINT #1, CHR$(2);E$;"A";E$;"V0100";E$;"H0100";E$;"GB006006";
PRINT #1 CHR$(&HFF);CHR$(&HFF);CHR$(&HFF);CHR$(&HFF); etc etc until the end of the pcx file.

here is what i have tried to do to solve this problem
private function print()

Dim printObj As String
Dim fs As FileStream = New FileStream("C:\Kosher.pcx", FileMode.Open)
Dim data(fs.Length) As Byte
Dim pos As Integer
Dim b As Byte

While fs.Length > pos
b = fs.ReadByte
data(pos) = b
pos = pos + 1
End While
fs.Close()
printObj = ByteArrayToString(data)

'TODO send data to printer (this part is working)
end sub

Public Function ByteArrayToString(ByVal bytArray() As Byte) As String
Dim UTF8 As New System.Text.UTF8Encoding
Return UTF8.GetString(bytArray)
End Function

but i'm not getting the correct results. suggestions?
cheers.
 
better basic example.
open "wiz.pcx" for input as #2
DA$ = INPUT$(15706, #2)
C$ = CHR$(27)
lprint C$; "V150"; C$ "H100"; C$ "GP15706,"; ...data...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top