Header Ads Widget

Generate Barcode in VB.NET

Generate Barcode in VB.NET

I am Creating Windows application using VB.Net. In this Article you will learn about Generate Barcode in VB.NET.
I am Creating windows application in vb.net named Generate Barcode in VB.NET. In this application I am using MessagingToolkit.dll, one Textbox, one PictureBox, Three Button controls and One Labels.

I am using Following Controls and it's name
txt_Barcode.Text : It is used to Enter the Barcode.
Pic_barcode.Image : It is used to Display Barcode.
Btn_Generate : It is used to get the Barcode.
Btn_save : It is used to Save Barcode.
Btn_Clear : It is used to Clear Barcode

Step 1 => Import MessagingToolkit.dll

Download MessagingToolkit.dll


Imports MessagingToolkit.Barcode
Step 2 => Barcode Generate Code

            Dim Generator As New MessagingToolkit.Barcode.BarcodeEncoder
            Generator.BackColor = Color.White
            Generator.LabelFont = New Font("Arial", 7, FontStyle.Regular)
            Generator.IncludeLabel = True
            Generator.CustomLabel = txt_barcode.Text
            Try
                Pic_barcode.Image = New Bitmap(Generator.Encode(MessagingToolkit.Barcode.BarcodeFormat.Code93, txt_barcode.Text))
            Catch ex As Exception
            End Try
Step 3 => Barcode Save My Computer

SD.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        SD.FileName = txt_barcode.Text
        SD.SupportMultiDottedExtensions = True
        SD.AddExtension = True
        SD.Filter = "PNG File|*.png"
        If SD.ShowDialog() = DialogResult.OK Then
            Try
                Pic_barcode.Image.Save(SD.FileName, Imaging.ImageFormat.Png)
            Catch ex As Exception
            End Try
        End If

Step 4 => Barcode Clear

Pic_barcode.Image= Nothing
txt_barcode.Clear()
txt_barcode.Focus()

Thanks

Happy Coding.....

Subscribe For More Projects...

Post a Comment

0 Comments