3

我正在尝试获取一个字符串并将其转换为 vb.net 中的代码 128 条形码。我是一名新手程序员,想知道有些人认为实现这一目标的最佳设计实践是什么。

一个简单的谷歌搜索已经产生了一些看似免费的解决方案。 http://www.onbarcode.com/vb_net/code-128-generator.html 例如

我也可以自己尝试这样做,但我不确定将字符串转换为条形码的确切方法。我将继续研究这一点,但如果有人已经知道了这一点,它可以为我节省一些时间。

提前致谢

4

5 回答 5

2

看看下面的代码项目页面 -条码图像生成库

这允许您从字符串生成所需格式的条形码图像。

这应该足以让你开始

于 2012-10-11T19:50:21.380 回答
2

如果您不想为条形码中的字符串转换编写任何代码并且不想购买外部组件,您可以使用我的 ItextSharp 库 ( http://sourceforge.net/projects/itextsharp/ )意见是实现目标的最简单方法。你可以在网上和 stackoverflow 上找到一些关于 itextsharp 的资源,主要是在 c# 和 vb.net 中。

对于条形码生成 vb.net 代码,您可以在这里查看:http: //professionalaspnet.com/archive/2008/11/09/A-Quick-and-Dirty-Bar-Code-Image-httpHandler.aspx

于 2012-11-05T14:59:44.807 回答
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")
于 2013-06-17T07:57:52.997 回答
0

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

  • 快速开发和完成
  • 学习经验
  • 便宜/免费(不包括汗水)

您的 google 链接显示了在该页面上显示示例代码的产品。那有什么问题?

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

于 2012-10-11T17:42:13.313 回答
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")
于 2014-10-11T07:25:49.803 回答