【问题标题】:Printing Code128 barcode using printer object in vb6 (using font)使用 vb6 中的打印机对象打印 Code128 条码(使用字体)
【发布时间】:2014-04-09 02:17:22
【问题描述】:

我们有一些古老的 vb6 程序,它使用依赖于窗口字体的打印机对象创建条码,该程序适用于 code39。 最近我们需要将字体切换到code128,经过一些工作我们将输入转换为code128格式的字符串,并尝试使用相同的方法打印,但是打印输出似乎不正确(奇怪的是,当我们将转换后的字符串复制到excel并使用相同的code 128字体打印出来,完美显示和打印出来)

我想知道是否有人有同样的经历,如果有,请问有人可以切碎一些灯吗?

以下是我们用来打印条形码的代码

dim sOrg as string
sOrg = "12345888"

printer.fontName = "code39"
printer.print sOrg    'This prints it out perfectly

'However when we change font to code
'this returns   Í,BZx}Î   which can be copy onto Excel and print out properly
sOrg = convertTo128(sOrg)   
printer.fontName = "Code 128"
printer.print sOrg     'print out with part barcode line, part squares 

【问题讨论】:

  • 如果Í,BZx}Î 打印为 ascii 字形,则打印机未使用您的 Code128 字体。将Printer 设置为正确的设备后,使用printer.fontName = "Code 128" : msgbox printer.fontName 确保它设置为“代码128”。如果您看到其他内容,请检查字体列表以查看您是否使用了正确的名称:for i = 0 to printer.fontCount: debug.? printer.Font(i): next
  • 感谢您的输入,但我已经检查并且字体名称是正确的。但是我们仍然打印出部分条形码(我怀疑诸​​如Í或Î之类的元素被打印为一些正方形,而诸如B或Z之类的字符被转换为类似条形码的线条),这可能与语言设置有关吗视窗? (但如果我们切换到 Arial 字体,它似乎可以正确打印出 Í,BZx}Î)
  • 如果您将字符串打印到表单/图片框,它是否打印正确? 1Í,BZx}Î 在我的 code128 字体中 = tinypic.com/view.php?pic=2d0o1f4&s=8#.UxmtLInesfQ
  • 是的,与使用打印机对象直接打印不同,它设法在图片框或文本框中打印出像图像一样的条形码,但只有在我使用表单 2.0 的文本框时才能正确打印(我猜它是到非ASCII字符;我使用的是中文窗口)。这是通过打印机对象直接打印的图像i59.tinypic.com/2uol4cp.jpg

标签: printing vb6 code128


【解决方案1】:

您可以使用以下包含VB6项目并打开条形码字体的项目

barcode fonts and encoders

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 2019-11-28
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多