using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using ZXing;
namespace BarcodeUtility
{
public partial class frmScanGenerate : Form
{
public frmScanGenerate()
{
InitializeComponent();
}
private void frmScanGenerate_Load(object sender, EventArgs e)
{
LblBarcode.Visible = false;
LblQRcode.Visible = false;
BtnPrintBarcode.Visible = false;
BtnPrintQRcode.Visible = false;
}
private void BtnExit_Click(object sender, EventArgs e)
{
this.Hide();
frmBarcodemain barcodemain = new frmBarcodemain();
barcodemain.ShowDialog();
}
int icount = 0;
private void BtnPaletStart_Click(object sender, EventArgs e)
{
LblBarcode.Visible = true;
LblQRcode.Visible = true;
BtnPrintBarcode.Visible = true;
BtnPrintQRcode.Visible = true;
dataGridViewScan.Rows.Clear();
for (int icount = 1; icount < 16; icount++)
{
string barcodeData = ScanBarcode();
dataGridViewScan.Rows.Add(icount, barcodeData);
}
GenerateBarcodeAndQRcode();
}
private string ScanBarcode()
{
//return "1234567890";
BarcodeScanner scanner = new BarcodeScanner(); // create a new instance of the barcode scanner
scanner.Connect();
string barcode = scanner.Scan(); // read the barcode from the scanner
scanner.Disconnect();
return barcode;
}
private void GenerateBarcodeAndQRcode()
{
// generate barcode
BarcodeWriter barcodeWriter = new BarcodeWriter();
barcodeWriter.Format = BarcodeFormat.CODE_128;
Bitmap barcodeBitmap = barcodeWriter.Write("1234567890");
// generate qrcode
BarcodeWriter qrCodeWriter = new BarcodeWriter();
qrCodeWriter.Format = BarcodeFormat.QR_CODE;
Bitmap qrCodeBitmap = qrCodeWriter.Write("1234567890");
// display barcode and qrcode
PictBarcodeImage.Image = barcodeBitmap;
PictQRcodeimage.Image = qrCodeBitmap;
}
}
}
Muhammad Imran AnsariPosted May 9, 2023, 7:38 AM
This error occurs because the BarcodeScanner class is not defined in the current code file or in a referenced library.
To fix this error, you need to ensure that the BarcodeScanner class is defined in a library that is referenced in the code file. Alternatively, if you have the source code for the library that defines the BarcodeScanner class, you can add the source code files to the project and build them along with the rest of the project.