Home > Software engineering >  Why don't file has been generated, the printer to print? The code is as follows:
Why don't file has been generated, the printer to print? The code is as follows:

Time:10-09

The Public Function PrintBarcode (printstr As String) As String

Dim m_port As String
M_port=ReadIni (" ZEBRA888T ", "port")

Dim arrPrint () As String
ArrPrint=Split (printstr, "^")

Open the App. The Path & amp; "\ print. TXT" For the Output As the # 1

'loop to print
'outer loop
Dim strPrint () As String
StrPrint=Split (printstr, "$")
Dim arrLen As Integer
ArrLen=UBound (strPrint) - LBound (strPrint) + 1
Dim printstring print content As the String '
Printstring=""

For k=0 To arrLen - 1
Dim strParam () As String
StrParam=Split (strPrint (k), "^")
'inner loop
'loop to print


'to print the label on the waybill
Print # 1, #!" A1 "
Print # 1, # IMSR65.02/55.03 "" 'label width, height
Print # 1, # HV65 "concentration
'Print # 1, # PR4/4 "/" 'printing speed
Print # 1, # RX0 "
Print # 1, # N13 "
Print # 1, # ERN/1//"0"

'here is a print content
Print # 1, "# # # T09.91 J04.06 YN901/0 42 u////" & amp; StrParam (3) & amp; "# G 'characters
"Print # 1, "# # # T07.96 J39.20 YN101/0/42///YN101 # G" 'character
Print # 1, "# # # T06.52 J35.48 YL0/74.25/0/00.51" crossed
'Print # 1, "# # # T07.20 J16.00 YB13/0 p2. 0 m/13.46/4///# 12343578329-3124 G" barcode
'
Print '
Print # 1, # # Q1 "G"
Print # 1, #!" P1 "
Next

Close # 1
On the Error Resume Next

'file character set conversion
Dim filename As String, (b) As Byte, S As String
Dim ADO_Stream As Object
Filename=App. Path & amp; "\ print. TXT" 'please amend for the specific file name
'If Dir (FileName)="" Then Exit Sub
ReDim b (FileLen (filename))
The Open filename For Binary As # 1
Get # 1, and b
Close # 1
S=StrConv (b, vbUnicode)

The Set ADO_Stream=CreateObject (" ADODB. Stream ")

With ADO_Stream
Type=2
. Mode=3
The Charset="utf-8"
. Open
. WriteText S
SaveToFile filename, 2
End With

The Set ADO_Stream=Nothing


FileCopy App. Path & amp; "\ print. TXT", m_port

If Err. Number & lt;> 0 Then
ZebraPrint="please make sure the printer port Settings right" 'Err. The Description
The Else
ZebraPrint=""
End the If
End the Function



Don't like FileCopy identified why?

CodePudding user response:

The
refer to the original poster weihualeiok response:
Public Function PrintBarcode (printstr As String) As String

Dim m_port As String
M_port=ReadIni (" ZEBRA888T ", "port")

Dim arrPrint () As String
ArrPrint=Split (printstr, "^")

.

LZ code is the code for the output to a text file.
Printing need organization code like this:
 Private Sub Command1_Click () 
Dim As Integer I
Open "LPT1" For the Output As the # 1
Print # 1, CRH (27); CRH (64) 'removal of the original print Settings, namely the initialization
Print # 1, CRH (28) & amp; "@" 'set up Chinese state
Pnt1
Print # 1, CRH (28) & amp; "J" 'set longitudinal printing Chinese characters
Pnt1
Print # 1, CRH (28) & amp; "K" 'set up Chinese characters laterally print
Print # 1, CRH (27); "3"; CRH (45) 'set the line width
Print # 1, CRH (27); "W". CRH (1) the four times' set amplifier
Print # 1, CRH (27); "Q"; CRH (3) 'set the hollow words
Pnt1
Print # 1, CRH (27); CRH (64) 'removal of the original print Settings, namely the initialization
For I=3 To 24 Step 3 'execution character space adjustment
Print # 1, CRH (28); "S"; CRH (0); CRH (I)
Pnt1
Next
Print # 1, CRH (28); "S"; CRH (0); CRH (3)
Print # 1, CRH (27); "4". 'set the italics
Print # 1, CRH (27); "Q"; CRH (3) 'set the hollow words
Pnt1
'Print # 1, CRH (28) & amp; ". "' switch back to the western state
Close # 1
End Sub

Private Sub Form_Load ()
Text1=""
Open "LPT1" For the Output As the # 1
Print # 1, CRH (27); CRH (64) 'removal of the original print Settings, namely the initialization
The Close
End Sub

Public Sub pnt1 ()
Print # 1, and "LPT1:" & amp; "Printer" in both English and Chinese with heart
End Sub

Print is committed or use the Printer.

CodePudding user response:

What I want from the automatically generated Print. TXT read sent to the printer to Print, the content of the

'to print the label on the waybill
Print # 1, #!" A1 "
Print # 1, # IMSR65.02/55.03 "" 'label width, height
Print # 1, # HV65 "concentration
'Print # 1, # PR4/4 "/" 'printing speed
Print # 1, # RX0 "
Print # 1, # N13 "
Print # 1, # ERN/1//"0"

This is a tag contents be to Print. TXT in
Is sent to the printer out barcode,

Now what I want from this Print. TXT in
Read the content sent to the printer for printing,

Dim m_port As String
M_port=ReadIni (" ZEBRA888T ", "port")
This is the printer port to read configuration files,

I think with FileCopy App. Path & amp; "\ print. TXT", m_port can invoke the printer but no effect,

CodePudding user response:

CodePudding user response:

I've done! Thank you, I was thinking about it to print the contents of the input into a TXT text in the call from the text,
Now can print directly

CodePudding user response:

reference 4 floor weihualeiok response:
I've done! Thank you, I was thinking about it to print the contents of the input into a TXT text in the call from the text,
Direct printing can now

Experience is the best they can to solve the problem.

CodePudding user response:

Dim arrPrint () As String
ArrPrint=Split (printstr, "^")

"Open the App. The Path & amp; "\ print. TXT" For the Output As the # 1
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related