0% found this document useful (0 votes)
16 views3 pages

Generate PRN Labels with QR Codes

The document outlines a Visual Basic script that generates a PRN file for printing labels based on data from a DataGridView. It constructs the PRN file by looping through the rows of the DataGridView to extract item codes, rates, and names, and formats them into a specific layout for printing. Finally, it uses a batch file to send the generated PRN file to a specified printer.

Uploaded by

simha80
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Generate PRN Labels with QR Codes

The document outlines a Visual Basic script that generates a PRN file for printing labels based on data from a DataGridView. It constructs the PRN file by looping through the rows of the DataGridView to extract item codes, rates, and names, and formats them into a specific layout for printing. Finally, it uses a batch file to send the generated PRN file to a specified printer.

Uploaded by

simha80
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Dim xWholePageBook As String = ""

Dim xLablePage As String = ""

'Generate PRN file as Per the BarTender Design Generated

Dim line1 As String = "SIZE 102.6 mm, 25 mm"


Dim line2 As String = "DIRECTION 0,0"
Dim line3 As String = "REFERENCE 0,0"
Dim line4 As String = "OFFSET 0 mm"
Dim line5 As String = "SET PEEL OFF"
Dim line6 As String = "SET CUTTER OFF"
Dim line7 As String = "SET PARTIAL_CUTTER OFF"
Dim line8 As String = "SET TEAR ON"
Dim line9 As String = "CLS"
Dim line10 As String = "CODEPAGE 1252"

Dim xHead As String = line1 & vbCrLf & _


line2 & vbCrLf & _
line3 & vbCrLf & _
line4 & vbCrLf & _
line5 & vbCrLf & _
line6 & vbCrLf & _
line7 & vbCrLf & _
line8 & vbCrLf & _
line9 & vbCrLf

With dgvLablePrint

Dim xPRNstrning As String = ""


Dim xNoOfLable As Integer = 1
Dim xNoOfCopy As Integer = 1

Dim xFirstItemCode As String = ""


Dim xFirstItemRate As String = ""
Dim xFirstItemName As String = ""

Dim xTotalPrintRows As Integer = .RowCount - 1

'LOOP through the Datagirdview to print the No of Label to be PRINT


'Genarting PRN file as per the Qty, Rate and Product QR Code

For i = 0 To .RowCount - 1

'Chech wherether grid loop have next row or not. unitl loop finish
the entire Line Item

'First column Label data


If i <= xTotalPrintRows Then
xFirstItemCode = .Rows(i).Cells(1).Value 'Item Code for
QR Code
xFirstItemRate = .Rows(i).Cells(4).Value 'Item Rate Code
xFirstItemName = .Rows(i).Cells(3).Value 'Item Name
Else
xFirstItemCode = "-"
xFirstItemRate = "-"
xFirstItemName = "-"
End If
'Assign the Gird Cell Vaule (Rate & Product Code) to the PRN text
file string

Dim xItemQRCode1 As String = "QRCODE 800,150,L,5,A,180,M2,S7,""" &


_
xFirstItemCode & """"
Dim xItemCode1 As String = "TEXT 800,39,""[Link]"",180,1,7,""" &
_
xFirstItemCode & """"
Dim xRs1 As String = "TEXT 800,175,""[Link]"",180,1,6,""" & _
xFirstItemName & """"
'Dim xItemRate1 As String = "TEXT 692,112,""[Link]"",180,1,9,"""
& _
'xFirstItemRate & """"

Dim xItemRate1 As String = "TEXT 652,12,""0"",90,8,9,""" & _


xFirstItemRate & """"

'Concatenate all line into single line

xLablePage = line10 & vbCrLf & _


xItemQRCode1 & vbCrLf & xItemCode1 & vbCrLf & xRs1 &
vbCrLf & xItemRate1 & vbCrLf & _
"PRINT " & xNoOfLable & "," & xNoOfCopy & "" & vbCrLf &
"CLS" & vbCrLf

'Per loop Concatenate whole pages with single page

xWholePageBook = xWholePageBook & vbCrLf & xLablePage


xLablePage = ""

'Increase or Step Up loop as per the LABEL per Page


'Each page have 4 label. So Increase Loop by 4 (i+3)

i = i + 3

Next

'Generate PRN File using StreamWriter

xPRNstrning = xHead & vbCrLf & xWholePageBook


Dim file As [Link]
Dim xFilePath As String = "D:\DATA\[Link]"

[Link](xFilePath, "")
file = [Link](xFilePath, True)
[Link](xPRNstrning)
[Link]()

'Windows Batch File send PRN file to Printer for Print Job-->
Lable_Print_1x4.bat
'This Windows BATCH Command in Text
'COPY /B D:\Lable_Print_1x4.prn \\[Link]\BarCodePrinterTT065-50

Dim psi As New ProcessStartInfo("D:\Data\Lable_Print_1x4.bat")


[Link] = True
[Link] = True
[Link] = False
[Link] = [Link]
[Link] = False

Dim process As Process = [Link](psi)

End With

End Sub

You might also like