ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 2581|回复: 3

[求助] VB条形码打印示例运行错误

[复制链接]

TA的精华主题

TA的得分主题

发表于 2011-2-23 16:32 | 显示全部楼层 |阅读模式
请教,下面代码运行提示"编译错误,类型不匹配",在FORM1.

不知是哪里有问题,请帮忙,谢谢


Private Sub Command1_Click()
  PrintBarCode "d", 1, 1, "s"
End Sub

Public Sub PrintBarCode(TransNo As String, LineNo As Long, QtyStored As Long, SerialNo As String)
  'Note: No spaces is allowed in the double-qoute of barcode printing syntax
  'BarCode Printer Model : B-572-QP (Toshiba Tec)
  
  Dim ESC: Dim LF: Dim NUL
  
  ESC = Chr$(&H1B): LF = Chr$(&HA): NUL = Chr$(&H0)
  
  Open "LPT1" For Output As #1
    'Set initial setting
    Print #1, ESC; "AY;+00,0"; LF; NUL;
    Print #1, ESC; "D0980,1280,0940"; LF; NUL;

    Print #1, ESC; "C"; LF; NUL;

    Print #1, ESC; "XR;0000,0000,1280,0940,A"; LF; NUL;
    Print #1, ESC; "AX;+000,+000,+00"; LF; NUL;
    Print #1, ESC; "U2;0130"; LF; NUL;

    'Print barcode parameters
    Print #1, ESC; "XB01;0050,0150,3,1,03,03,07,07,02,0,0090,+0000000000,0,00"; LF; NUL; 'PartNo Barcode
    Print #1, ESC; "XB02;0810,0150,3,1,03,03,07,07,02,0,0090,+0000000000,0,00"; LF; NUL; 'BatchNo Barcode
    Print #1, ESC; "XB03;0050,0645,3,1,03,03,07,07,02,0,0090,+0000000000,0,00"; LF; NUL; 'Transfer Order Barcode
    Print #1, ESC; "XB04;0810,0645,3,1,03,03,07,07,02,0,0090,+0000000000,0,00"; LF; NUL; 'DeliveryNo Barcode

    'Print label heading parameters
    Print #1, ESC; "PC001;0050,0290,05,05,M,+00,00,B"; LF; NUL; 'PartNo
    Print #1, ESC; "PC002;0830,0290,05,05,M,+00,00,B"; LF; NUL; 'BatchNo
    Print #1, ESC; "PC003;0050,0340,05,05,M,+00,00,B"; LF; NUL; 'Old Part No
    Print #1, ESC; "PC004;0050,0390,05,05,M,+00,00,B"; LF; NUL; 'SerialNo
    Print #1, ESC; "PC005;0830,0390,05,05,M,+00,00,B"; LF; NUL; 'Qty + UOM
    Print #1, ESC; "PC006;0050,0440,05,05,M,+00,00,B"; LF; NUL; 'Description
    Print #1, ESC; "PC007;0050,0490,05,05,M,+00,00,B"; LF; NUL; 'Sales Order No
    Print #1, ESC; "PC008;0830,0490,05,05,M,+00,00,B"; LF; NUL; 'Sales LineNo
    Print #1, ESC; "PC009;0050,0540,05,05,M,+00,00,B"; LF; NUL; 'Cust RefNo
    Print #1, ESC; "PC010;0050,0590,05,05,M,+00,00,B"; LF; NUL; 'Cust Part No
    Print #1, ESC; "PC011;0130,0800,05,05,M,+00,00,B"; LF; NUL; 'Transfer Order
    Print #1, ESC; "PC012;0480,0800,05,05,M,+00,00,B"; LF; NUL; 'Transfer LineNo
    Print #1, ESC; "PC013;0780,0800,05,05,M,+00,00,B"; LF; NUL; 'Storage Type
    Print #1, ESC; "PC014;1080,0800,05,05,M,+00,00,B"; LF; NUL; 'DeliveryNo
    Print #1, ESC; "PC015;0070,0920,05,05,M,+00,00,B"; LF; NUL; 'Footer

    'Print label information parameters
    Print #1, ESC; "PC016;0290,0290,2,2,G,+00,00,B"; LF; NUL; 'PartNo
    Print #1, ESC; "PC017;0950,0290,2,2,G,+00,00,B"; LF; NUL; 'BatchNo
    Print #1, ESC; "PC018;0310,0340,2,2,G,+00,00,B"; LF; NUL; 'Old Part No
    Print #1, ESC; "PC019;0265,0390,2,2,G,+00,00,B"; LF; NUL; 'SerialNo
    Print #1, ESC; "PC020;0940,0390,2,2,G,+00,00,B"; LF; NUL; 'Qty + UOM
    Print #1, ESC; "PC021;0290,0440,2,2,G,+00,00,B"; LF; NUL; 'Description
    Print #1, ESC; "PC022;0445,0490,2,2,G,+00,00,B"; LF; NUL; 'Sales Order No
    Print #1, ESC; "PC023;0940,0490,2,2,G,+00,00,B"; LF; NUL; 'Sales LineNo
    Print #1, ESC; "PC024;0270,0540,2,2,G,+00,00,B"; LF; NUL; 'Cust RefNo
    Print #1, ESC; "PC025;0350,0590,2,2,G,+00,00,B"; LF; NUL; 'Cust Part No
    Print #1, ESC; "PC026;0070,0850,2,2,G,+00,00,B"; LF; NUL; 'Transfer Order
    Print #1, ESC; "PC027;0480,0850,2,2,G,+00,00,B"; LF; NUL; 'Transfer LineNo
    Print #1, ESC; "PC028;0740,0850,2,2,G,+00,00,B"; LF; NUL; 'Storage Type
    Print #1, ESC; "PC029;0980,0850,2,2,G,+00,00,B"; LF; NUL; 'DeliveryNo
   
    'Stamp heading to print
    Print #1, ESC; "RC001;Part Number:"; LF; NUL;  'PartNo
    Print #1, ESC; "RC002;Batch:"; LF; NUL;  'BatchNo
    Print #1, ESC; "RC003;Old Part No.:"; LF; NUL;  'Old Part No
    Print #1, ESC; "RC004;Serial No.:"; LF; NUL;  'SerialNo
    Print #1, ESC; "RC005;Qty.:"; LF; NUL; 'Qty + UOM
    Print #1, ESC; "RC006;Description:"; LF; NUL;  'Description
    Print #1, ESC; "RC007;MTU Sales Order No.:"; LF; NUL;  'Sales Order No
    Print #1, ESC; "RC008;Line:"; LF; NUL;  'Sales LineNo
    Print #1, ESC; "RC009;Cust. Ref.:"; LF; NUL;  'Cust RefNo
    Print #1, ESC; "RC010;Cust. Part No.:"; LF; NUL;  'Cust Part No
    Print #1, ESC; "RC011;TO"; LF; NUL; 'Transfer Order
    Print #1, ESC; "RC012;TO LINE"; LF; NUL;  'Transfer LineNo
    Print #1, ESC; "RC013;ST"; LF; NUL;  'Storage Type
    Print #1, ESC; "RC014;DN"; LF; NUL;  'DeliveryNo
    Print #1, ESC; "RC015;Proper storage and preservation of parts prolong shelf life"; LF; NUL;  'Footer

    'Stamp data to print
    Print #1, ESC; "RB01;" & txtPart & ""; LF; NUL;  'PartNo Barcode
    If txtBatch <> "" Then Print #1, ESC; "RB02;" & txtBatch & ""; LF; NUL; 'BatchNo Barcode
    Print #1, ESC; "RB03;" & txtTO & ""; LF; NUL;  'Transfer Order Barcode
    If txtDO <> "" Then Print #1, ESC; "RB04;" & txtDO & ""; LF; NUL;  'DeliveryNo Barcode

    Print #1, ESC; "RC016;" & txtPart & ""; LF; NUL;  'PartNo
    If txtBatch <> "" Then Print #1, ESC; "RC017;" & txtBatch & ""; LF; NUL;  'BatchNo
    If txtOldPart <> "" Then Print #1, ESC; "RC018;" & txtOldPart & ""; LF; NUL;  'Old Part No
    If txtSn <> "0" Then Print #1, ESC; "RC019;" & txtSn & ""; LF; NUL;  'SerialNo
    Print #1, ESC; "RC020;" & Form1 & "" & IIf(txtUOM <> "", txtUOM, "") & ""; LF; NUL; 'Qty + UOM
    If txtDesc <> "" Then Print #1, ESC; "RC021;" & txtDesc & ""; LF; NUL;  'Description
    If txtSO <> "" Then Print #1, ESC; "RC022;" & txtSO & ""; LF; NUL;  'Sales Order No
    If txtLine <> "" Then Print #1, ESC; "RC023;" & txtLine & ""; LF; NUL;  'Sales LineNo
    If txtCustRef <> "" Then Print #1, ESC; "RC024;" & txtCustRef & ""; LF; NUL;  'Cust RefNo
    If txtCustPart <> "" Then Print #1, ESC; "RC025;" & txtCustPart & ""; LF; NUL;  'Cust Part No
    Print #1, ESC; "RC026;" & txtTO & ""; LF; NUL; 'Transfer Order
    Print #1, ESC; "RC027;" & txtTOLine & ""; LF; NUL;  'Transfer LineNo
    If txtST <> "" Then Print #1, ESC; "RC028;" & txtST & ""; LF; NUL;  'Storage Type
    If txtDO <> "" Then Print #1, ESC; "RC029;" & txtDO & ""; LF; NUL;  'DeliveryNo
   
    Print #1, ESC; "LC;0050,0755,1280,0755,0,4"; LF; NUL; 'Horizontal Seperator
    Print #1, ESC; "LC;0050,0875,1280,0875,0,4"; LF; NUL; 'Horizontal Separator
    Print #1, ESC; "LC;0420,0755,0420,0875,0,4"; LF; NUL; 'Vertical Separator
    Print #1, ESC; "LC;0710,0755,0710,0875,0,4"; LF; NUL; 'Vertical Separator
    Print #1, ESC; "LC;0960,0755,0960,0875,0,4"; LF; NUL; 'Vertical Separator

    'Print barcode
    Print #1, ESC; "XS;I,0001,0003C3100"; LF; NUL;
    Print #1, ESC; "U1;0130"; LF; NUL

  Close #1
  
End Sub

TA的精华主题

TA的得分主题

发表于 2011-2-24 21:23 | 显示全部楼层

传附件啊。高手会出手的。

传附件啊。高手会出手的。

TA的精华主题

TA的得分主题

发表于 2011-2-24 18:05 | 显示全部楼层

〖Excel Home友情提示〗

   

很遗憾通知楼上朋友,您的帖子在24小时之内没有任何回复!

通常情况下,本论坛发布的主题帖会在8小时被回复或处理。您的帖子在24小时之内未被回复,其中的原因可能是

1、问题表述不清、模棱两可,难以理解,帮助者被搞晕了,夺帖而出;
2、没有上传必要的附件,或附件被遗忘在某个角落;
3、发帖提问时,语气带棱角、带挑衅,不幸被列入不受欢迎的帖子;
4、所提问题不成立,或提不合理的要求,乐于助人者使出“走为上”之计;
5、话题较偏、较冷或者发布到了不合适的版块,暂时无人问津,顾影自怜。


为了提高您的问题解决效率,我们推荐您阅读以下文章:
* 如何发表新话题和上传附件:http://club.excelhome.net/thread-45649-1-1.html
* 发帖的技巧:http://club.excelhome.net/thread-176339-1-1.html
* EH技术论坛的最佳学习方法:http://club.excelhome.net/thread-117862-1-1.html

TA的精华主题

TA的得分主题

发表于 2011-2-24 19:00 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-6-18 03:05 , Processed in 0.043095 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表