程序:
Public Sub PrintCode(mObjPic As Object, strCode As String, OffsetX As Integer, OffsetY As Integer, blnHaveText As Boolean)
Dim strBC As String, ChrBC As String, BCCode As String, X As Integer, Y As Integer, h As Integer
Dim i As Integer, j As Integer, k As Integer
Static strBarTable(39) As String '注释: 初始化条码编码格式表
strBarTable(0) = "101001101101" '注释: 0
strBarTable(1) = "110100101011" '注释: 1
strBarTable(2) = "101100101011" '注释: 2
strBarTable(3) = "110110010101" '注释: 3
strBarTable(4) = "101001101011" '注释: 4
strBarTable(5) = "110100110101" '注释: 5
strBarTable(6) = "101100110101" '注释: 6
strBarTable(7) = "101001011011" '注释: 7
strBarTable(8) = "110100101101" '注释: 8
strBarTable(9) = "101100101101" '注释: 9
strBarTable(10) = "110101001011" '注释: A
strBarTable(11) = "101101001011" '注释: B
strBarTable(12) = "110110100101" '注释: C
strBarTable(13) = "101011001011" '注释: D
strBarTable(14) = "110101100101" '注释: E
strBarTable(15) = "101101100101" '注释: F
strBarTable(16) = "101010011011" '注释: G
strBarTable(17) = "110101001101" '注释: H
strBarTable(18) = "101101001101" '注释: I
strBarTable(19) = "101011001101" '注释: J
strBarTable(20) = "110101010011" '注释: K
strBarTable(21) = "101101010011" '注释: L
strBarTable(22) = "110110101001" '注释: M
strBarTable(23) = "101011010011" '注释: N
strBarTable(24) = "110101101001" '注释: O
strBarTable(25) = "101101101001" '注释: P
strBarTable(26) = "101010110011" '注释: Q
strBarTable(27) = "110101011001" '注释: R
strBarTable(28) = "101101011001" '注释: S
strBarTable(29) = "101011011001" '注释: T
strBarTable(30) = "110010101011" '注释: U
strBarTable(31) = "100110101011" '注释: V
strBarTable(32) = "110011010101" '注释: W
strBarTable(33) = "100101101011" '注释: X
strBarTable(34) = "110010110101" '注释: Y
strBarTable(35) = "100110110101" '注释: Z
strBarTable(36) = "100101011011" '注释: -
strBarTable(37) = "101001001001" '注释: %
strBarTable(38) = "100100100101" '注释: $
strBarTable(39) = "100101101101" '注释: *
X = OffsetX
Y = OffsetY
h = sngBarHeight
' X = mObjPic.ScaleX(OffsetX, vbMillimeters, vbTwips)
' Y = mObjPic.ScaleY(OffsetY, vbMillimeters, vbTwips)
' h = mObjPic.ScaleY(intHeight, vbMillimeters, vbTwips) strBC = UCase(strCode)
If Left(strBC, 1) <> "*" Then strBC = "*" & strBC
If Right(strBC, 1) <> "*" Then strBC = strBC & "*"
If blnHaveText = True Then h = h - mObjPic.TextHeight(strBC) '条码打印高度要减去下面的字符显示高度
With mObjPic
.ScaleMode = vbTwips
.DrawWidth = 1
.FontName = "宋体"
.FontSize = 8
End With
For i = 0 To Len(strBC) - 1
ChrBC = Mid(strBC, i + 1, 1)
BCCode = strBarTable(GetBarCode(ChrBC))
'当前字符
If blnHaveText = True Then
mObjPic.CurrentX = X
mObjPic.CurrentY = Y + h
mObjPic.Print ChrBC
End If For j = 0 To Len(BCCode) - 1
'窄
If Mid(BCCode, j + 1, 1) = "0" Then
X = X + SngSpaceWidth
'宽
Else
For k = 0 To SngLineWidth - 1
mObjPic.Line (X + k, Y)-Step(0, h)
Next k
X = X + SngLineWidth
End If
Next
'字间距
X = X + SngDetWidth
Next
Exit SubEnd Sub怎么用呀,
Public Sub PrintCode(mObjPic As Object, strCode As String, OffsetX As Integer, OffsetY As Integer, blnHaveText As Boolean)
Dim strBC As String, ChrBC As String, BCCode As String, X As Integer, Y As Integer, h As Integer
Dim i As Integer, j As Integer, k As Integer
Static strBarTable(39) As String '注释: 初始化条码编码格式表
strBarTable(0) = "101001101101" '注释: 0
strBarTable(1) = "110100101011" '注释: 1
strBarTable(2) = "101100101011" '注释: 2
strBarTable(3) = "110110010101" '注释: 3
strBarTable(4) = "101001101011" '注释: 4
strBarTable(5) = "110100110101" '注释: 5
strBarTable(6) = "101100110101" '注释: 6
strBarTable(7) = "101001011011" '注释: 7
strBarTable(8) = "110100101101" '注释: 8
strBarTable(9) = "101100101101" '注释: 9
strBarTable(10) = "110101001011" '注释: A
strBarTable(11) = "101101001011" '注释: B
strBarTable(12) = "110110100101" '注释: C
strBarTable(13) = "101011001011" '注释: D
strBarTable(14) = "110101100101" '注释: E
strBarTable(15) = "101101100101" '注释: F
strBarTable(16) = "101010011011" '注释: G
strBarTable(17) = "110101001101" '注释: H
strBarTable(18) = "101101001101" '注释: I
strBarTable(19) = "101011001101" '注释: J
strBarTable(20) = "110101010011" '注释: K
strBarTable(21) = "101101010011" '注释: L
strBarTable(22) = "110110101001" '注释: M
strBarTable(23) = "101011010011" '注释: N
strBarTable(24) = "110101101001" '注释: O
strBarTable(25) = "101101101001" '注释: P
strBarTable(26) = "101010110011" '注释: Q
strBarTable(27) = "110101011001" '注释: R
strBarTable(28) = "101101011001" '注释: S
strBarTable(29) = "101011011001" '注释: T
strBarTable(30) = "110010101011" '注释: U
strBarTable(31) = "100110101011" '注释: V
strBarTable(32) = "110011010101" '注释: W
strBarTable(33) = "100101101011" '注释: X
strBarTable(34) = "110010110101" '注释: Y
strBarTable(35) = "100110110101" '注释: Z
strBarTable(36) = "100101011011" '注释: -
strBarTable(37) = "101001001001" '注释: %
strBarTable(38) = "100100100101" '注释: $
strBarTable(39) = "100101101101" '注释: *
X = OffsetX
Y = OffsetY
h = sngBarHeight
' X = mObjPic.ScaleX(OffsetX, vbMillimeters, vbTwips)
' Y = mObjPic.ScaleY(OffsetY, vbMillimeters, vbTwips)
' h = mObjPic.ScaleY(intHeight, vbMillimeters, vbTwips) strBC = UCase(strCode)
If Left(strBC, 1) <> "*" Then strBC = "*" & strBC
If Right(strBC, 1) <> "*" Then strBC = strBC & "*"
If blnHaveText = True Then h = h - mObjPic.TextHeight(strBC) '条码打印高度要减去下面的字符显示高度
With mObjPic
.ScaleMode = vbTwips
.DrawWidth = 1
.FontName = "宋体"
.FontSize = 8
End With
For i = 0 To Len(strBC) - 1
ChrBC = Mid(strBC, i + 1, 1)
BCCode = strBarTable(GetBarCode(ChrBC))
'当前字符
If blnHaveText = True Then
mObjPic.CurrentX = X
mObjPic.CurrentY = Y + h
mObjPic.Print ChrBC
End If For j = 0 To Len(BCCode) - 1
'窄
If Mid(BCCode, j + 1, 1) = "0" Then
X = X + SngSpaceWidth
'宽
Else
For k = 0 To SngLineWidth - 1
mObjPic.Line (X + k, Y)-Step(0, h)
Next k
X = X + SngLineWidth
End If
Next
'字间距
X = X + SngDetWidth
Next
Exit SubEnd Sub怎么用呀,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货