Printer.DrawWidth = 1 注释: 线宽为 1
Printer.FontName = "宋体" 注释: 打印在条码下方字符的字体和大小
Printer.FontSize = 10
Dim strBC As String 注释: 要打印的条码字符串 逆风编程精品
strBC = Ucase(strBarCode)
注释: 将以毫米表示的 X 坐标转换为以缇表示
Dim x As Integer
x = Printer.ScaleX(intXPos, vbMillimeters, VBTwips)
注释: 将以毫米表示的 Y 坐标转换为以缇表示
Dim y As Integer
y = Printer.ScaleY(intYPos, vbMillimeters, VBTwips)
注释: 将以毫米表示的高度转换为以缇表示
Dim intHeight As Integer
intHeight = Printer.ScaleY(intPrintHeight, vbMillimeters, VBTwips)
注释: 是否在条形码下方打印人工识别字符
If bolPrintText = True Then
注释: 条码打印高度要减去下面的字符显示高度
intHeight = intHeight - Printer.TextHeight(strBC)
End If
Const intWidthCU As Integer = 30 注释: 粗线和宽间隙宽度
Const intWidthXI As Integer = 10 注释: 细线和窄间隙宽度
Dim intIndex As Integer 注释: 当前处理的字符串索引
Dim i As Integer, j As Integer, k As Integer 注释: 循环控制变量
注释: 添加起始字符
If Left(strBC, 1) <> "*" Then
strBC = "*" & strBC
End If
注释: 添加结束字符
If Right(strBC, 1) <> "*" Then
strBC = strBC & "*"
End If
注释: 循环处理每个要显示的条码字符
For i = 1 To Len(strBC)
注释: 确定当前字符在 strBarTable 中的索引
Select Case Mid(strBC, i, 1)
Case "*"
intIndex = 39
Case "$"
intIndex = 38
Case "%"
intIndex = 37
Case "-"
intIndex = 36
Case "0" To "9"
intIndex = CInt(Mid(strBC, i, 1))
Case "A" To "Z"
intIndex = Asc(Mid(strBC, i, 1)) - Asc("A") 10
Case Else
MsgBox "要打印的条形码字符串中包含无效字符!当前版本只支持字符 注释:0注释:-注释:9注释:,注释:A注释:-注释:Z注释:,注释:-注释:,注释:%注释:,注释:$注释:和注释:*注释:"
End Select
注释: 是否在条形码下方打印人工识别字符
If bolPrintText = True Then
Printer.CurrentX = x
Printer.CurrentY = y intHeight
Printer.Print Mid(strBC, i, 1)
End If
For j = 1 To 5
注释: 画细线
If Mid(strBarTable(intIndex), j, 1) = "0" Then
For k = 0 To intWidthXI - 1
Printer.Line (x k, y)-Step(0, intHeight)
Next k
x = x intWidthXI
注释: 画宽线
Else
For k = 0 To intWidthCU - 1
Printer.Line (x k, y)-Step(0, intHeight)
Next k
x = x intWidthCU
End If
注释: 每个字符条码之间为窄间隙
If j = 5 Then
x = x intWidthXI * 3
Exit For
End If
注释: 窄间隙
If Mid(strBarTable(intIndex), j 5, 1) = "0" Then
x = x intWidthXI * 3 本文章更多内容:<<上一页 - 1 - 2 - 3 - 4 - 下一页>> |