Hi there, I have done this programming in java and it works but can't make it run in vb6 (and I need to)
Basically I need to send data to zebra printer over the network. The whole process works (no error reported but the printer does not print. In Java I have used:
public void printOnions(ArrayList<String> DataArr){
// LH is x,y coordinates for starting position
// FO is x,y coordinates to start current print
// BY sets the barcode size
// BC is code128 then orientation, height,
// print interpretation line, print above barcode,
// check digit
// A is font type, height and width
// FD data start, FS data end
String BarCode = DataArr.get(2) + "-" + DataArr.get(3);
transferType = "^MTT"; // use thermal transfer
String ZPLString = "^LH5,5" + transferType + // Sets the type to thermal transfer
"^BY2" + "^MNM" +
"^FO50,30" + "^ADN,96,20^FD" + DataArr.get(0) + " " + DataArr.get(1) + "^FS" +
"^FO250,130" + "^BCN,70,N,N,N" + "^FD" + BarCode + "^FS" +
"^FO50,230" + "^ADN,96,20^FD" + BarCode + " " + DataArr.get(4) + "^FS";
PrtTags(ZPLString);
}
public void initializeZPL(String printerIn) throws IOException {
try {
//create stream objs
int port = 9100;
Socket sock = new Socket(printerIn, port);
ostream = new FileOutputStream(printerIn);
pstream = new PrintStream(sock.getOutputStream() );
} catch (UnknownHostException ex) {
Logger.getLogger(ZebraZPLView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ZebraZPLView.class.getName()).log(Level.SEVERE, null, ex);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
}
}
public void PrtTags(String ZPLString){
try{
ZPLString = "^XA" + ZPLString + "^XZ";
char[] chars = ZPLString.toCharArray();
pstream.print(chars);
// pstream.close();
pstream.flush();
}
catch (Exception e) {
e.printStackTrace();
}
}
This is vb6:
Dim Buffer() As Byte
Dim printer As String
printer = "ZBR3677984"
If sock.State = sckClosed Then
sock.RemoteHost = printer
sock.RemotePort = 9100
sock.Connect
Me.txtPrice.Text = "connected" & vbNewLine & sock.LocalHostName _
& vbNewLine & CStr(sock.RemotePort) _
& vbNewLine & CStr(sock.RemoteHost)
Dim ZPLString As String
ZPLString = "^LH10,10" & "^MTT" & "^BY2" & "^MNM" & _
"^FO15,0" & "^ADN,36,20^FD" & "Line-1 " & " Line 2 " & "^FS" & _
"^FO15,50" & "^ADN,56,40^FD" & "line-3 " & "^FS" & _
"^FO100,100" & "^BCN,70,N,N,N" & "^FD" & "line-4" & "^FS" & _
"^FO15,190" & "^ADN,56,40" & "^FD" & "line-5" & "^FS" & _
"^FO15,250" & "^BCN,70,N,N,N" & "^FD" & "line-6" & "^FS"
ZPLString = "^XA" + ZPLString + "^XZ"
ZPLString = "^XA" + "test" + "^XZ"
ReDim Buffer(Len(ZPLString)) As Byte
Buffer = ZPLString
sock.SendData Buffer
End If
I am missing some king of NetworkStream to print. Does anybody have a line of thought ? Very much appreciated
Dallag