Click here to Skip to main content
14,113,296 members
Click here to Skip to main content
Add your own
alternative version


65 bookmarked
Posted 7 Jul 2007
Licenced CPOL

Barcode UPC-A

, 7 Jul 2007
Rate this:
Please Sign up or sign in to vote.
UPC-A C# class that will generate UPC-A codes
Screenshot - Untitled.jpg


This application will allow you to generate a UPC-A barcode. It includes the checksum feature.


I originally built this application in VB.NET. While I was learning C#.NET, I decided to re-write it in C#.NET because at the time I was learning that application. I built this application about a year ago, and have not looked at the code since then. I was just hoping someone could really benefit from it. All I ask is if you do use it, please email me, and let me know how you used it, and proper credit (my name) would be cool, but not necessary.

Using the Code

  1. First create a new instance of the cUPCA class.
  2. Checksum to correct the input value with the correct last number, or to check to see if it is a valid UPC-A barcode.
  3. Create a new instance of an image.
  4. Set the back color to white.
  5. Pull back from the class to the image (this contains the barcode and numbers).
  6. Set your image to equal the image of the barcode.

cUPCA upca = new cUPCA();
if(this.txtTextToAdd.Text.Length == 12)
  this.txtTextToAdd.Text = this.txtTextToAdd.Text.Substring(0, 11) + 
  Image img;
  img = upca.CreateBarCode(this.txtTextToAdd.Text, 2);
  this.pctBarCode.Left = System.Convert.ToInt32(
    (this.pnlWhiteBack.Width / 2) - (img.Width / 2));
  this.pctBarCode.Image = img;
  this.pctBarCode.Image = null;

Points of Interest

To test this application, I bought a barcode scanner from Ebay for 5 dollars, and it works. I printed the barcodes out on paper with my laser printer, and they scan perfectly. I am also at times able to scan the barcode from the actual screen.

It was just a fun project that allowed me to learn a little bit more about the graphics class.

For the checksum class, I used the same code that was used in this article.


  • 7th July, 2007: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Bill Daugherty II
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionDo you have vertion for this Pin
ibrahimp9-Jan-13 1:53
memberibrahimp9-Jan-13 1:53 
QuestionThanks a Lot Pin
navyivan22-Oct-12 7:02
membernavyivan22-Oct-12 7:02 
GeneralThanks alot Pin
Mahmoud Farouk18-Oct-12 8:51
memberMahmoud Farouk18-Oct-12 8:51 
QuestionMessage Closed Pin
23-Feb-12 4:33
memberWebMaster23-Feb-12 4:33 
Generalbarcode in code 39 Pin
Member 79252208-Jul-11 22:26
memberMember 79252208-Jul-11 22:26 
QuestionPossible to have more than 13 charactor? Pin
adcom8013-Oct-08 22:18
memberadcom8013-Oct-08 22:18 
QuestionScanning of Barcode Pin
LalithKumar3-Jun-08 21:49
memberLalithKumar3-Jun-08 21:49 
QuestionBarcode Background Pin
LalithKumar3-Jun-08 21:33
memberLalithKumar3-Jun-08 21:33 
Questionexplain codeproject ~~~~! Pin
chinaQI8-Jul-07 2:10
memberchinaQI8-Jul-07 2:10 
AnswerRe: explain codeproject ~~~~! Pin
Bill Daugherty II8-Jul-07 6:11
memberBill Daugherty II8-Jul-07 6:11 
GeneralRe: explain codeproject ~~~~! Pin
chinaQI8-Jul-07 20:30
memberchinaQI8-Jul-07 20:30 
GeneralRe: explain codeproject ~~~~! Pin
Bill Daugherty II9-Jul-07 2:01
memberBill Daugherty II9-Jul-07 2:01 
GeneralRe: explain codeproject ~~~~! Pin
chinaQI9-Jul-07 5:16
memberchinaQI9-Jul-07 5:16 
Generalfirst-rate code! Pin
chinaQI8-Jul-07 1:33
memberchinaQI8-Jul-07 1:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190518.1 | Last Updated 7 Jul 2007
Article Copyright 2007 by Bill Daugherty II
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid