Barcode - Visual Basic tutorial. Create and read barcodes in VB. - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Barcode – Visual Basic tutorial. Create and read barcodes in VB.

  • Home
  • /
  • Articles
  • /
  • Barcode – Visual Basic tutorial. Create and read barcodes in VB.

Barcode Visual Basic tutorial shows how to create barcode and save it to image file in Visual Basic with BarCode Generator SDK and read barcode from image using BarCode Reader SDK.

Use this source code to create Code 39 barcode in VB with Barcode Generator SDK:

Imports Bytescout.BarCode

Module Module1

   Sub Main()
       ' Create new barcode
       Dim barcode As New Barcode()

       ' Set symbology
       barcode.Symbology = SymbologyType.Code39
       ' Set value
       barcode.Value = "Sample"

       ' Save barcode to image
       barcode.SaveImage("result.png")

       ' Show image in default image viewer
       Process.Start("result.png")
   End Sub

End Module

Read Code 39 barcode from image in VB using Barcode Reader SDK:

Imports System.IO

Imports Bytescout.BarCodeReader

Module Module1

   Sub Main()
       Dim pat As String = "result.png"
       Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(pat))

       Dim bc As New Reader()

       bc.TypeToFind = SymbologyFilter.FindCode39

       Dim barcodes As FoundBarcode() = bc.ReadFrom(pat)

       Dim i As Integer
       For i = 0 To barcodes.Length - 1
           Console.WriteLine("Found barcode with type '{0}' and value '{1}'", barcodes(i).Type, barcodes(i).Value)
       Next

       Console.WriteLine("Press any key to exit..")
       Console.ReadKey()
   End Sub

End Module

Tutorials:

prev
next