Barcode for Crystal Report > Generate Barcode in VB

Create Barcodes in Crystal Reports Using VB.NET

How to Generate 1D and Matrix Barcode in Crystal Reports Using Visual Basic Class
Introduction of KA.Barcode for Crystal Reports
KeepAutomation Crystal Reports Barcode Generator free demo is a reliable barcode component sdk that can be used in .NET language environment (such as C# & VB.NET programming) to generate standard barcodes in Crystal Reports automatically.
KeepAutomation provides free tutorial for developers to create barcode images. This barcode generator control library is compatible with multiple widely-used windows systems. It's simple to use this freeware trial version to abstract large numbers of barcode pictures.
Compatibility & Requirements
  • Development Environments: Visual Studio 2005 or above versions, Visual C#, Visual Basic.NET, Crystal Reports for .NET (runtime), .NET Framework 2.0, or greater
  • Operating System Compatibility: Windows Vista / Windows7 / Windows XP / Window Server 2005 / 2008
Test Environment
  • Microsoft Windows XP
  • Microsoft Visual Studio 2005
  • Visual Basic .NET
Generate Barcodes in Crystal Reports in WinForms Using VB

Evaluation Package Overview
Download Demo Package of KeepAutomation Barcode Generator for Crystal Reports and unzip. It is allowed to completely implement or display functions of barcode images in document for various applications, including transaction, medicine & console applications. With this barcode generator library, implementers may import characters into project for barcode generation.
This demo package is always used to capture graphics barcode images using VB code. It is also used to resize barcode images through height, length, human-readable text, etc.

Display the demo dataset "KACrystalData.mdb" from the unzipped evaluation package, you will find a table named "Product" with three columns inside: "ID", "ProductId", "ProductName".

There is a CustomerDataSet.xsd file for "KACrystalData.mdb" that is used to define the above three columns in "Product" table as well as an extra column named "Barcode".
Use VB.NET Class to Generate Barcodes for Crystal Reports in WinForms
  1. Create a new .NET project with "Crystal Reports Application" as template. Name the project as "CrystalReportsBarcode".
  2. Using the Report Wizard to create a new report, and choose "Standard", and click "OK" button.
  3. Expand "Create New Connection", find "ADO.NET" in "Data" form and expand it.
  4. In "Connection" form, select the "ProductDataSet.xsd" in your unzipped package. Then click "Finish" button.
  5. In "Data" form, add table "Product" and click "Next".
  6. In "Fields" form, add all three columns in the table "Product". Click "Finish".
  7. In CrystalReport1.rpt, drag and drop "Barcode" in the "Field Explorer" to the report Section 3.
  8. In .NET project "solution explorer", add "KeepAutomation.Barcode.Crystal.dll" to your project reference.
  9. Open your "Form1.cs", copy the following demo code and run the report.
VB Sample code
     Dim aConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/KACrystalData.mdb")
aConnection.Open()

Dim dataAdapter As New OleDbDataAdapter("select * from Product", aConnection)
Dim ds As New DataSet()
dataAdapter.Fill(ds)

'Add the Barcode column to the DataSet
ds.Tables(0).Columns.Add(New DataColumn("Barcode", GetType(Byte())))

'Create an instance of Linear Barcode
'Use DataMatrixCrystal for Data Matrix
'Use PDF417Crystal for PDF417
'Use QRCodeCrystal for QR Code
Dim barcode As New BarCode()
'Barcode settings
barcode.Symbology = KeepAutomation.Barcode.Symbology.UPCA
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

For Each dr As DataRow In ds.Tables(0).Rows
barcode.CodeToEncode = CInt(dr("ProductId")) & ""
Dim imageData As Byte() = barcode.generateBarcodeToByteArray()
dr("Barcode") = imageData
Next
CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport1.rpt"))
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables(0))
CrystalReportSource1.DataBind()
Generate Barcodes in Crystal Reports in Web Forms Using VB
  1. Open your Visual Studio, create a new web project with "ASP.NET Crystal Reports Web Site" as template;
  2. Create a new report "Using the Report Wizard", choose "Standard", and click "OK";
  3. In "Data" form, double click "Create New Connection", and expand "ADO.NET".
  4. In "ADO.NET" form, select "ProductDataSet.xsd" file in your downloaded package, and click "Finish" button.
  5. In "Data" form, add table "Product" and click "Next".
  6. In "Fields" form, add all three columns in the table "Product". Click "Finish".
  7. In CrystalReport1.rpt, add field "Barcode" to the report Section 3;
  8. Add "KeepAutomation.Barcode.Crystal.dll" to your project reference in "Solution Explorer";
  9. Right click "Default.aspx" in"Solution Explorer" and choose "View Code";
  10. Use the following demo code accordingly and run the project.
VB Sample code
     Dim aConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/KACrystalData.mdb")
aConnection.Open()
Dim dataAdapter As New OleDbDataAdapter("select * from Product", aConnection)
Dim ds As New DataSet()
dataAdapter.Fill(ds)
'add a new column named "Barcode" to the DataSet, the new column data type is byte[]
ds.Tables(0).Columns.Add(New DataColumn("Barcode", GetType(Byte())))
Dim barcode As New BarCode()
barcode.Symbology = KeepAutomation.Barcode.Symbology.EAN13
For Each dr As DataRow In ds.Tables(0).Rows
barcode.CodeToEncode = CInt(dr("ProductId")) & ""
Dim imageData As Byte() = barcode.generateBarcodeToByteArray()
dr("Barcode") = imageData
Next
Dim rpt As New CrystalReport1()
rpt.SetDataSource(ds)
Me.crystalReportViewer1.ReportSource = rpt
aConnection.Close()
CompatibilityTest EnvironmentFor Windows VBFor Web VBUsing C#Using VB.NETUsing ASP.NETUsing .NET WinformsData Matrix for Crystal ReportPDF417 for Crystal ReportQR Code for Crystal ReportmoreCodabar for Crystal ReportCode 39 for Crystal ReportCode 128 for Crystal ReportEAN-8 for Crystal ReportEAN-13 for Crystal ReportEAN 128 for Crystal ReportIntelligent Mail for Crystal ReportInterleaved 2 of 5 for Crystal ReportISBN for Crystal ReportITF-14 for Crystal ReportRM4SCC for Crystal ReportUPC-A for Crystal ReportUPC-E for Crystal Reportmore
KeepAutomation provides complete barcode automation solutions for add barcode display 2-dimensional, barcode generation capacity api, and barcode mobile applications. We recommend the customers use high quality ASP.NET html5 document viewer, c# pdf sdk, C# merge PDF files, Split PDF in C#, C# View, edit PDF online , C# Convert PDF to Tiff, C# Convert PDF to text, txt, .net imaging sdk, C# PDF metadata edit from RasterEdge.com.