ByteScout BarCode Generator SDK - VB.NET - DisplayBarcodeOnForm - ByteScout

ByteScout BarCode Generator SDK – VB.NET – DisplayBarcodeOnForm

  • Home
  • /
  • Articles
  • /
  • ByteScout BarCode Generator SDK – VB.NET – DisplayBarcodeOnForm

ByteScout BarCode Generator SDK – VB.NET – DisplayBarcodeOnForm

Form1.vb

Imports System.Drawing
Imports System.Windows.Forms
Imports Bytescout.BarCode

' This application demonstrates two ways how you can show the barcode on a form: 
' 1. using PictureBox control;
' 2. painting it on a Panel control.
Public Partial Class Form1
	Inherits Form
	Private _barcode As Barcode = Nothing

	Public Sub New()
		InitializeComponent()

		' Create Barcode Generator instance
		_barcode = New Barcode()
		_barcode.RegistrationName = "demo"
		_barcode.RegistrationKey = "demo"

		' Setup barcode
		_barcode.Symbology = SymbologyType.QRCode
		_barcode.Value = "Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing"

		' Put the barcode image to PictureBox
		pictureBox1.Image = _barcode.GetImage()
	End Sub

	' Paint the barcode image on a Panel control
	Private Sub panel1_Paint(sender As Object, e As PaintEventArgs)
		Dim barcodeImage As Image = _barcode.GetImage()

		e.Graphics.DrawImage(barcodeImage, 0, 0)
	End Sub
End Class

Program.vb

Imports System.Collections.Generic
Imports System.Windows.Forms

NotInheritable Class Program
	Private Sub New()
	End Sub
	''' <summary>
	''' The main entry point for the application.
	''' </summary>
	<STAThread> _
	Friend Shared Sub Main()
		Application.EnableVisualStyles()
		Application.SetCompatibleTextRenderingDefault(False)
		Application.Run(New Form1())
	End Sub
End Class


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next