.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

barcode reader..

Posted By: gopal     Posted Date: July 31, 2009    Points:2   Category :Windows Application
How to read barcode in C# or vb.net (windows).
In Detail: for example, library management: read the barcode of all books.
So can please tell me the how to write code for the reading the barcode and that barcode must be stored in database.

need ur suggestions


Author: Amit Mehra             
Posted Date: August 01, 2009     Points: 5   

All you need a barcode scanner and which will return you the value and from C# you have to catch the return value from scanner..for this you need 3rd party software..see the detail discussion about reading the Bar code value from C# here


Please "Mark As Answer " if this post help you.
Author: krishana singh             
Posted Date: December 09, 2010     Points: 5   

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Barcodes

/// <summary />
/// Summary description for BarCode.
/// </summary />

public class BarCode : System.Web.UI.Page
private void Page_Load(object sender, System.EventArgs e)
// Get the Requested code to be created.
string Code = Request["code"].ToString();

// Multiply the lenght of the code by 40 (just to have enough width)
int w = Code.Length * 40;

// Create a bitmap object of the width that we calculated and height of 100
Bitmap oBitmap = new Bitmap(w,100);

// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);

// Now create a Font object for the Barcode Font
// (in this case the IDAutomationHC39M) of 18 point size
Font oFont = new Font("IDAutomationHC39M", 18);

// Let's create the Point and Brushes for the barcode
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);

// Now lets create the actual barcode image
// with a rectangle filled with white color
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);

// We have to put prefix and sufix of an asterisk (*),
// in order to be a valid barcode
oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);

// Then we send the Graphics with the actual barcode
Response.ContentType = "image/jpeg" ;
oBitmap.Save (Response.OutputStream, ImageFormat.Jpeg);
Let's test our page. Just call http://localhost/BarCodes/BarCode.aspx?Code=1234.

As you can see, there is a barcode with the value of 1234.

Now, let's create a page that has an asp:Image on it:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="BarCodes.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Image id="myBarCode" runat="server"></asp:Image>
Add this to the code behind:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace BarCodes
/// <summary />
/// Summary description for WebForm1.
/// </summary />
public class WebForm1 : System.Web.UI.Page
protected System.Web.UI.WebControls.Image myBarCode;

private void Page_Load(object sender, System.EventArgs e)
// Put user code to initialize the page here
myBarCode.ImageUrl = "BarCode.aspx?code=31231";

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.

/// <summary />
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary />
private void InitializeComponent()
this.Load += new System.EventHandler(this.Page_Load);

Now, let's see the result:

Well friends, that is all! An easy and cheap way to have barcodes in your ASP.NET applications.


Author: EddyCrusie             
Posted Date: December 19, 2012     Points: 20   

Another easy way to read barcode in C# or vb.net in ASP.NET applications is to use a barcode reading control. Check this: http://www.keepdynamic.com/dotnet-barcode-reader/code-39.shtml

Author: hark             
Posted Date: February 16, 2013     Points: 20   

If you just need the codes instead of the barcode reading sdk, maybe this website can help you

But you can also analyze some existed dll, like

Author: dsfsgds             
Posted Date: March 19, 2013     Points: 20   

Actually, it's just as easy as creating barcode in C#(http://www.onbarcode.com/tutorial/csharp-barcode-generation.html ) or creating barcode in VB.NET(http://www.onbarcode.com/tutorial/vb-net-barcode-generation.html ) . As they say , you just need a third party control. You can put "C# barcode reader" in google, you can find much useful information like this.

Author: arronlee             
Posted Date: June 20, 2013     Points: 20   

Nice sharing.
But I used to read barcode from local image [http://www.yiigo.com/net-document-image-plugin/barcode-plugin/barcode-read.shtml] with another third party plugin which allow users to integrate this .NET Barcode Reader into to add advanced barcode reading to your .NET image viewer and empower users with the ability to include an image viewer and pre-processing capabilities such as deskew, despeckle, and annotations.
It is just one of many but I do appreciate its simple way of processing.
Even though I only tried its free trial package and didn´t check the cost and licensing conditions, it works great for me.
Share with you.
BTW, I wonder whether the free tools online have as many professional fuctions as the paid ones.
But I will try your sharing later and find more.
Many thanks again.

Best Regards,

Next Tomorrow is Another Day .
Author: recthor             
Posted Date: June 23, 2013     Points: 20   

I think some imaging sdk programmes can enable to quickly scan barcodes. i have use imaging sdkr which can original layouts hyperlinks, Images and tables retained in word ,text, image, Epub, html.but i forgot download the wedsite ,go to google. By the way , pay attention to your system platform, select the suitable one . I use a barcode scanner driver found on the internet . Install it and it becomes a selectable option.Then you can scan barcodes in many formats in any program at all, including Adobe Acrobat . Just open the sdk, select barcode, and choice a form you want, then you can scan barcode in c#, vb, sdp ,etc ,the task will be finished in several seconds. if you haven't found a good choice , you can have a try. best wishes.

Author: sonfacesd             
Posted Date: July 25, 2013     Points: 20   

I used this barcode reader to read barcode in C#:
Not bad one!

Author: cindy313             
Posted Date: August 28, 2013     Points: 20   

i've ever used barcode reader in .net (http://www.keepautomation.com/products/net_barcode_reader/ ),which scans and recognizes barcodes from any directions in C#, VB class and console application

Author: cindy313             
Posted Date: October 23, 2013     Points: 20   

hey,recently,i wanna find a barcode reader for my phone ,do you guys have any ideaa except this .net barcode reader i mentioned before http://www.keepautomation.com/products/net_barcode_reader/barcode_data_matrix.html

Author: Xavier.z             
Posted Date: December 18, 2013     Points: 20   

There are many different barcode types and the easiest way to support them all is to use a toolkit such as the one mentioned in this article:

Author: brent-me             
Posted Date: May 21, 2014     Points: 20   

Here's a cool barcode generator I've been using, which can help you check out the reader you're working on.

Author: longwest             
Posted Date: July 01, 2015     Points: 20   

Please refer to:
Here's guide for both c# and vb.net code for reading barcode.

Best regards.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend