Link Search Menu Expand Document

Display Barcode On Form - VB.NET

BarCode SDK sample in VB.NET demonstrating ‘Display Barcode On Form’

Form1.Designer.vb
��Partial Class Form1

	''' <summary>

	''' Required designer variable.

	''' </summary>

	Private components As System.ComponentModel.IContainer = Nothing



	''' <summary>

	''' Clean up any resources being used.

	''' </summary>

	''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

	Protected Overrides Sub Dispose(disposing As Boolean)

		If disposing AndAlso (components IsNot Nothing) Then

			components.Dispose()

		End If

		MyBase.Dispose(disposing)

	End Sub



	#Region "Windows Form Designer generated code"



	''' <summary>

	''' Required method for Designer support - do not modify

	''' the contents of this method with the code editor.

	''' </summary>

	Private Sub InitializeComponent()

		Me.pictureBox1 = New System.Windows.Forms.PictureBox()

		Me.panel1 = New System.Windows.Forms.Panel()

		Me.label1 = New System.Windows.Forms.Label()

		Me.label2 = New System.Windows.Forms.Label()

		DirectCast(Me.pictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()

		Me.SuspendLayout()

		' 

		' pictureBox1

		' 

		Me.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

		Me.pictureBox1.Location = New System.Drawing.Point(12, 36)

		Me.pictureBox1.Name = "pictureBox1"

		Me.pictureBox1.Size = New System.Drawing.Size(270, 270)

		Me.pictureBox1.TabIndex = 0

		Me.pictureBox1.TabStop = False

		' 

		' panel1

		' 

		Me.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

		Me.panel1.Location = New System.Drawing.Point(314, 36)

		Me.panel1.Name = "panel1"

		Me.panel1.Size = New System.Drawing.Size(270, 270)

		Me.panel1.TabIndex = 1

		AddHandler Me.panel1.Paint, New System.Windows.Forms.PaintEventHandler(AddressOf Me.panel1_Paint)

		' 

		' label1

		' 

		Me.label1.AutoSize = True

		Me.label1.Location = New System.Drawing.Point(12, 9)

		Me.label1.Name = "label1"

		Me.label1.Size = New System.Drawing.Size(179, 13)

		Me.label1.TabIndex = 2

		Me.label1.Text = "Show barcode in PictureBox control:"

		' 

		' label2

		' 

		Me.label2.AutoSize = True

		Me.label2.Location = New System.Drawing.Point(311, 9)

		Me.label2.Name = "label2"

		Me.label2.Size = New System.Drawing.Size(157, 13)

		Me.label2.TabIndex = 3

		Me.label2.Text = "Draw barcode on Panel control:"

		' 

		' Form1

		' 

		Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)

		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

		Me.ClientSize = New System.Drawing.Size(599, 349)

		Me.Controls.Add(Me.label2)

		Me.Controls.Add(Me.label1)

		Me.Controls.Add(Me.panel1)

		Me.Controls.Add(Me.pictureBox1)

		Me.Name = "Form1"

		Me.Text = "Form1"

		DirectCast(Me.pictureBox1, System.ComponentModel.ISupportInitialize).EndInit()

		Me.ResumeLayout(False)

		Me.PerformLayout()



	End Sub



	#End Region



	Private pictureBox1 As System.Windows.Forms.PictureBox

	Private panel1 As System.Windows.Forms.Panel

	Private label1 As System.Windows.Forms.Label

	Private label2 As System.Windows.Forms.Label

End Class




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

Resources.Designer.vb
��'------------------------------------------------------------------------------

' <auto-generated>

'     This code was generated by a tool.

'     Runtime Version:2.0.50727.8000

'

'     Changes to this file may cause incorrect behavior and will be lost if

'     the code is regenerated.

' </auto-generated>

'------------------------------------------------------------------------------



Namespace Properties





	''' <summary>

	'''   A strongly-typed resource class, for looking up localized strings, etc.

	''' </summary>

	' This class was auto-generated by the StronglyTypedResourceBuilder

	' class via a tool like ResGen or Visual Studio.

	' To add or remove a member, edit your .ResX file then rerun ResGen

	' with the /str option, or rebuild your VS project.

	<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")> _

	<System.Diagnostics.DebuggerNonUserCodeAttribute> _

	<System.Runtime.CompilerServices.CompilerGeneratedAttribute> _

	Friend Class Resources



		Private Shared resourceMan As Global.System.Resources.ResourceManager



		Private Shared resourceCulture As Global.System.Globalization.CultureInfo



		<System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")> _

		Friend Sub New()

		End Sub



		''' <summary>

		'''   Returns the cached ResourceManager instance used by this class.

		''' </summary>

		<System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _

		Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager

			Get

				If (resourceMan Is Nothing) Then

					Dim temp As New Global.System.Resources.ResourceManager("DisplayBarcodeOnForm.Properties.Resources", GetType(Resources).Assembly)

					resourceMan = temp

				End If

				Return resourceMan

			End Get

		End Property



		''' <summary>

		'''   Overrides the current thread's CurrentUICulture property for all

		'''   resource lookups using this strongly typed resource class.

		''' </summary>

		<System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _

		Friend Shared Property Culture() As Global.System.Globalization.CultureInfo

			Get

				Return resourceCulture

			End Get

			Set

				resourceCulture = value

			End Set

		End Property

	End Class

End Namespace


Settings.Designer.vb
��'------------------------------------------------------------------------------

' <auto-generated>

'     This code was generated by a tool.

'     Runtime Version:2.0.50727.8000

'

'     Changes to this file may cause incorrect behavior and will be lost if

'     the code is regenerated.

' </auto-generated>

'------------------------------------------------------------------------------



Namespace Properties





	<System.Runtime.CompilerServices.CompilerGeneratedAttribute> _

	<System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")> _

	Friend NotInheritable Partial Class Settings

		Inherits Global.System.Configuration.ApplicationSettingsBase



		Private Shared defaultInstance As Settings = DirectCast(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings)



		Public Shared ReadOnly Property [Default]() As Settings

			Get

				Return defaultInstance

			End Get

		End Property

	End Class

End Namespace


Download Source Code (.zip)

Return to the previous page Explore BarCode SDK


Copyright © 2016 - 2021 ByteScout