使用VB.NET生成Code 128条形码

3
我正在尝试将一个字符串转换成vb.net中的code 128条形码。作为一名初学者,我想知道有哪些最佳实践方法可以完成这个任务。通过简单的谷歌搜索,我找到了几个看起来免费的解决方案,例如http://www.onbarcode.com/vb_net/code-128-generator.html
我也可以尝试自己完成这个任务,但我不确定如何将字符串转换成条形码。我会继续研究这个问题,但如果有人已经知道这个问题的答案,那么就可以节省我的时间。
谢谢提前!

我可以给你128EAN在C#中的代码,甚至可以将其转换为VB.net。当然,没有人给过我这个代码... - Tony Hopkinson
5个回答

2
请查看以下codeproject页面:条形码图像生成库 这可以让您从字符串中生成所需格式的条形码图像。
这应该足以让您入门。

2

谢谢,实际上我有一个具有这个功能的外部组件,但我不知道它。但是我会给你信用,因为你是唯一一个用有帮助的帖子回答了我的问题。 - Brandon

1
以下示例来自:

http://www.onbarcode.com/tutorial/vb-net-barcode-generation.html

生成条形码。
 Dim barcode As OnBarcode.Barcode.Linear
    ' Create linear barcode object
    barcode = New OnBarcode.Barcode.Linear()
    ' Set barcode symbology type to Code-39
    barcode.Type = OnBarcode.Barcode.BarcodeType.CODE39
    ' Set barcode data to encode
    barcode.Data = "0123456789"
    ' Set barcode bar width (X    dimension) in pixel
    barcode.X = 1
    ' Set barcode bar height (Y dimension) in pixel
    barcode.Y = 60
    ' Draw & print generated barcode to png image file
    barcode.drawBarcode("C://vbnet-code39.png")

绘图和打印
 Dim qrCode As OnBarcode.Barcode.QRCode
    ' Create QRCode object
    qrCode = New OnBarcode.Barcode.QRCode()
    ' Set QR Code data to encode
    qrCode.Data = "VB.NET QRCode"
    ' Set QRCode data mode (QR-Code Barcode Settings)
    qrCode.DataMode = OnBarcode.Barcode.QRCodeDataMode.Auto
    ' Draw & print generated QR Code to jpeg image file
    qrCode.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
    qrCode.drawBarcode("C://vbnet-qrcode.jpg")

0

您可以使用此代码在VB编程中生成和输出code128图像。请参考以下Visual Basic示例代码,您可以尝试在VB.NET中生成code128

VB示例代码

 Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode
 code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto
 code128.CodeToEncode = "0128"

 'Apply checksum for Code 128 barcode.
 code128.ChecksumEnabled = True
 'Display checksum in the Code 128 barcode text
 code128.DisplayChecksum = True

 'Unit of measure, Pixel, Cm and Inch supported. 
 code128.BarcodeUnit = KeepAutomation.Barcode.BarcodeUnit.Pixel
 'Code 128 image resolution in DPI.
 code128.DPI = 72

 'Set Size for Generated Code 128 image

 'Code 128 bar module width (X dimention)
 code128.X = 2
 'Code 128 barcode image width (X dimention)
 code128.BarCodeWidth = 100
 'Code 128 bar module height (Y dimention)
 code128.Y = 60

 'Image left margin size, a 10X is automatically added according to specification.
 code128.LeftMargin = 0
 'Image right margin size, a 10X is automatically added according to specification.
 code128.RightMargin = 0
 'Code 128 image top margin size'
 code128.TopMargin = 0
 'Code 128 image bottom margin size'
 code128.BottomMargin = 0

 'Orientation, 90, 180, 270 degrees supported' Code 128 image bottom margin size
 code128.Orientation = KeepAutomation.Barcode.Orientation.Degree0
 'Code 128 image formats in Png, Gif, Jpeg/Jpg, Tiff, Bmp/Bitmap, etc.
 code128.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

 'Set Code 128 human readable text style

 code128.DisplayText = True
 code128.TextFont = New Drawing.Font("Arial", 10.0F, Drawing.FontStyle.Regular)
 'Space between barcode and text
 code128.TextMargin = 6

 code128.generateBarcodeToImageFile("C://code128-vb-net.png")

这对你有帮助吗? - bobbell2

0

你需要质疑你的目标。那个答案将驱动你的方法论。

  • 快速开发和完成
  • 学习经验
  • 便宜/免费(除去汗水投入)

你的 Google 链接显示了一个在同一页上显示示例代码的产品。这有什么问题吗?

你的目标输出是什么?报告对象,还是直接打印到打印机/标签上?


学习经验是首要的,但我完成这个项目的时间有限。在将对象发送到打印机之前,我将为其分配条形码。 - Brandon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接