谁有VB用的条码生成的控件,给我一个?(急用)
各位好心人,谁有VB用的条码生成的控件,给我一个?最好有例子源码,一维条码就行,能生成,能识别
急啊。
我的QQ:123274857 E-Mail:www-net@163.com --------------------编程问答-------------------- 网上抄的 经过验证 使用正常
--------------------编程问答-------------------- 新建一个标准工程,添加一个名为(Microsoft Access BarCode Control9)的条形码部件,并添加一个条码控件到窗口 --------------------编程问答-------------------- 一楼的,识别怎么办,你的代码是什么编吗方式的,是code39吧 --------------------编程问答--------------------
Public Sub PrintBarCode(ByVal strBarCode As String, _
Optional ByVal intXPos As Integer = 0, _
Optional ByVal intYPos As Integer = 0, _
Optional ByVal intPrintHeight As Integer = 10, _
Optional ByVal bolPrintText As Boolean = True, _
Optional ByVal Thin As Integer = 10, _
Optional ByVal Thick As Integer = 30)
' 参数说明:
' strBarCode - 要打印的条形码字符串
' intXPos, intYPos - 打印条形码的左上角坐标(缺省为(0,0),坐标刻度为:毫米)
' intHeight - 打印高度(缺省为一厘米,坐标刻度为:毫米)
' bolPrintText - 是否打印人工识别字符(缺省为true)
' Thin - 粗线和宽间隙宽度 默认 10
' Thick - 细线和窄间隙宽度 默认 30
' "0"-"9","A-Z","-","%","$"和"*" 的条码编码格式,总共 40 个字符
Static strBarTable(39) As String
' 初始化条码编码格式表
strBarTable(0) = "001100100" ' 0
strBarTable(1) = "100010100" ' 1
strBarTable(2) = "010010100" ' 2
strBarTable(3) = "110000100" ' 3
strBarTable(4) = "001010100" ' 4
strBarTable(5) = "101000100" ' 5
strBarTable(6) = "011000100" ' 6
strBarTable(7) = "000110100" ' 7
strBarTable(8) = "100100100" ' 8
strBarTable(9) = "010100100" ' 9
strBarTable(10) = "100010010" ' A
strBarTable(11) = "010010010" ' B
strBarTable(12) = "110000010" ' C
strBarTable(13) = "001010010" ' D
strBarTable(14) = "101000010" ' E
strBarTable(15) = "011000010" ' F
strBarTable(16) = "000110010" ' G
strBarTable(17) = "100100010" ' H
strBarTable(18) = "010100010" ' I
strBarTable(19) = "001100010" ' J
strBarTable(20) = "100010001" ' K
strBarTable(21) = "010010001" ' L
strBarTable(22) = "110000001" ' M
strBarTable(23) = "001010001" ' N
strBarTable(24) = "101000001" ' O
strBarTable(25) = "011000001" ' P
strBarTable(26) = "000110001" ' Q
strBarTable(27) = "100100001" ' R
strBarTable(28) = "010100001" ' S
strBarTable(29) = "001100001" ' T
strBarTable(30) = "100011000" ' U
strBarTable(31) = "010011000" ' V
strBarTable(32) = "110001000" ' W
strBarTable(33) = "001011000" ' X
strBarTable(34) = "101001000" ' Y
strBarTable(35) = "011001000" ' Z
strBarTable(36) = "000111000" ' -
strBarTable(37) = "100101000" ' %
strBarTable(38) = "010101000" ' $
strBarTable(39) = "001101000" ' *
If strBarCode = "" Then Exit Sub ' 不打印空串
'------------保存原有打印机设置
' 保存打印机 ScaleMode
Dim intOldScaleMode As ScaleModeConstants
intOldScaleMode = Printer.ScaleMode
' 保存打印机 DrawWidth
Dim intOldDrawWidth As Integer
intOldDrawWidth = Printer.DrawWidth
' 保存打印机 Font
Dim fntOldFont As StdFont
Set fntOldFont = Printer.Font
'------------设置打印机
Printer.ScaleMode = vbTwips ' 设置打印用的坐标刻度为缇(twip=1)
Printer.DrawWidth = 1 ' 线宽为 1
Printer.FontName = "宋体" ' 打印在条码下方字符的字体和大小
Printer.FontSize = 10
Dim strBC As String ' 要打印的条码字符串
strBC = UCase$(strBarCode)
' 将以毫米表示的 X 坐标转换为以缇表示
Dim X As Integer
X = intXPos
' 将以毫米表示的 Y 坐标转换为以缇表示
Dim Y As Integer
Y = intYPos
' 将以毫米表示的高度转换为以缇表示
Dim intHeight As Integer
intHeight = Printer.ScaleY(intPrintHeight, vbMillimeters, vbTwips)
' 是否在条形码下方打印人工识别字符
If bolPrintText = True Then
' 条码打印高度要减去下面的字符显示高度
intHeight = intHeight - Printer.TextHeight(strBC)
End If
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
'ws_WarningDlg "要打印的条形码字符串中包含无效字符!当前版本只支持字符 '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 Thin - 1
Printer.Line (X + k, Y)-Step(0, intHeight)
Next k
X = X + Thin
' 画宽线
Else
For k = 0 To Thick - 1
Printer.Line (X + k, Y)-Step(0, intHeight)
Next k
X = X + Thick
End If
' 每个字符条码之间为窄间隙
If j = 5 Then
X = X + Thin * 3
Exit For
End If
' 窄间隙
If Mid$(strBarTable(intIndex), j + 5, 1) = "0" Then
X = X + Thin * 3
' 宽间隙
Else
X = X + Thick * 2
End If
Next j
Next i
' 恢复打印机 ScaleMode
Printer.ScaleMode = intOldScaleMode
' 恢复打印机 DrawWidth
Printer.DrawWidth = intOldDrawWidth
' 恢复打印机 Font
Set Printer.Font = fntOldFont
End Sub
先打开记事本,再用扫描枪扫描条码即可 --------------------编程问答-------------------- [url=http://hi.baidu.com/dzerp/blog/item/fdf3f21e55ff066bf724e4d2.html]url]
--------------------编程问答-------------------- http://hi.baidu.com/dzerp/blog/item/fdf3f21e55ff066bf724e4d2.html --------------------编程问答-------------------- http://www.3800hk.com/Article/cxsj/c/jcjcc/2005-08-06/Article_39615.html --------------------编程问答--------------------
你确定了能用了吗?
动不动就贴代码.....易做图 --------------------编程问答--------------------
易做图 you...
老子又没让你用
--------------------编程问答-------------------- Microsoft Access BarCode Control9 --------------------编程问答--------------------
本来想贴个使用中的方案,一下子就忘了. --------------------编程问答-------------------- 怪了,现在年青人的脾气不是一般的大啊! --------------------编程问答-------------------- 飘过~ --------------------编程问答-------------------- 条码离了条码枪也就没意义了(当然,现在已经可以拍照识别)。
所以检验能不能用,最好的方法就是用条码枪照一下,
码枪相当于一个输入设备,其扫描动作,就相当于你输入了个字符(串)。
就像楼上某位所说,打开一个记事本,点一下,将焦点设置到记事本上,
按下扫描按钮,如果能读取出来,字符串就会自动输入到记事本上
(VB FORM下)实际使用的时候都是将焦点定位到某个输入框上,然后扫描的
最好是用现成的控件,比如大家提到的Microsoft Access BarCode Control9
补充:VB , 控件