如何在VB程序下生成二维条码
1、创建VB工程,COPY二维条码动态链接库到您的工程中。您需要引用的动态库有:EnCodePdf.dll,EnCodeQr.dll,EnDataMatrix和EnHanxin.dll。大家可以参照下图放置DLL和INI的目录位置。

3、进行条形码制作: 我们在薪姚蟪食引用API接口后,可以参照下面程序,实现接口调用 程序中txtfile表示文本文件名荑樊综鲶,binBmpFile表示输入的图像文件名 若需要装载图像可以采用Make开头接口,若不需要则采用En开头接口。 If (txtfile<> "" Or binBmpFile <> "") Then If m_bWorkMode = 1 Then ’PDF417 SetPdfConFile (Edit_ConFileName.Text) If (Edit_ImgFileName.Text <> "") Then strBmpFile = MakePdf417(txtfile, binBmpFile,"", "") Else strBmpFile = EnPdfText(Edit_Source.Text,"") End If ElseIf m_bWorkMode = 2 Then ’Qr_Code SetQrConFile (Edit_ConFileName.Text) If (Edit_ImgFileName.Text <> "") Then strBmpFile = MakeQrCode(txtfile, binBmpFile,"", "") Else strBmpFile = EnQrText(Edit_Source.Text,"") End If ElseIf m_bWorkMode = 3 Then ’ DataMatrix SetDmConFile (Edit_ConFileName.Text) If (Edit_ImgFileName.Text <> "") Then strBmpFile = MakeDataMatrix(txtfile,binBmpFile, "", "") Else strBmpFile = EnDmText(Edit_Source.Text,"") End If Else SetHxConFile (Edit_ConFileName.Text) If (Edit_ImgFileName.Text <> "") Then strBmpFile = MakeHanXin(txtfile, binBmpFile,"", "") Else strBmpFile = EnHxText(Edit_Source.Text,"") End If End If

4、打开关闭串口:条码编码控件一般自带串口接收处理接口:InitRead接口是初始化串口CloseRead接口是关闭串口If Cmd_OpenComm.Caption = "连接串口" Then Call SetPdfConFile(Edit_ConFileName.Text) If InitRead(Me.hwnd, App.Path + "\") = 1 Then Cmd_OpenComm.Caption = "断开串口" End IfElse ’关闭串口 If CloseRead() = 1 Then Cmd_OpenComm.Caption = "连接串口" End IfEnd If
5、接收条码识读器内容:串口收到识读器信息后,以键盘消息的形式,触发页面消息。我们调用FORM下,处理KeyDown事件。Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)Dim FileNo As IntegerDim strTmp As StringDim strBmpFile As StringstrBmpFile = App.Path & "\temp.bmp"If KeyCode = 255 Then FileNo = FreeFile() Open App.Path & "\temp.txt" For Input As #FileNo Edit_Source.Text = "" Do While Not EOF(FileNo) strTmp = "" Input #FileNo, strTmp Edit_Source.Text = Edit_Source.Text & strTmp & Chr(13) & Chr(10) Loop Close #FileNo If Dir(strBmpFile) <> "" Then Kill (strBmpFile) End If If Dir(App.Path & "\temp.img") <> "" Then If FileLen(App.Path & "\temp.img") > 10 Then Call Wdecompress(App.Path & "\temp.img", strBmpFile) End If End If If Dir(strBmpFile) <> "" Then Image_Bar.Picture = LoadPicture(strBmpFile) Else Image_Bar.Picture = LoadPicture("") End If Cmd_Print.Enabled = FalseEnd IfEnd Sub