2

I am creating Windows application using C#. Here i have 6 numbers

Batch Key:abc123
product Key:xyz456
Order key:mno789
batch Number:12345
product Number:45678
order key:97354

Here i want to generate random number using these 6 numbers and In a single button click i want generate Barcode for that random Number .

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Appu
  • 29
  • 2
  • 3

3 Answers3

2

Barcodes are simply fonts, you will need to download and incorporate a barcode font into your application.

See: http://www.dafont.com/barcode-font.font

Generate a random number between 0 and 100

Random random = new Random();
int randomNumber = random.Next(0, 100);
Justin Shield
  • 2,390
  • 16
  • 12
  • 2
    Note: A couple of things that caught me out were that some barcode formats require starting/closing characters such as an asterisk (easily added to your random number). Also some output formats such as Word altered the width of the font when printed which caused some scanner problems. Be sure to experiment. – Kynth Jul 06 '11 at 10:29
  • 2
    Be careful, instances of `Random` created in quick succession(withing a few milliseconds) return the same sequence of random numbers. – CodesInChaos Jul 06 '11 at 11:40
  • 3
    Barcodes aren't simply fonts. There are different formats of barcodes with different requirements such as start and stop characters, check digits and may be restricted in terms of the characters they may contain. This varies between the different specifications of barcodes. – Jason Jul 07 '11 at 09:01
0

First you should choose which barcode format to use (http://en.wikipedia.org/wiki/Barcode#Linear_barcodes). Once you know this you can use something like the Barcode Image Generation Library to generate your barcode image simply. This library can handle many different barcode specifications.

Jason
  • 1,065
  • 1
  • 16
  • 26
0

You may want to try Barcode.dll for barcode rendering:

http://www.lesnikowski.com/barcode/

It includes WinForms control - just drag & drop.

Please note that this is a commercial product I developed.

Pawel Lesnikowski
  • 6,264
  • 4
  • 38
  • 42