Leadtools.Barcode Requires Barcode add-on license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Code Property
See Also  Example
Leadtools.Barcode Namespace > BarcodeException Class : Code Property



Gets or sets the code that caused the exception.

Syntax

Visual Basic (Declaration) 
Public Property Code As BarcodeExceptionCode
Visual Basic (Usage)Copy Code
Dim instance As BarcodeException
Dim value As BarcodeExceptionCode
 
instance.Code = value
 
value = instance.Code
C# 
public BarcodeExceptionCode Code {get; set;}
C++/CLI 
public:
property BarcodeExceptionCode Code {
   BarcodeExceptionCode get();
   void set (BarcodeExceptionCode value);
}

Return Value

The exception code.

Example

Visual BasicCopy Code
Private Sub CodeExample()
   ' Load an image
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif")

   ' Initialize linear barcodes
   BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d)
   Dim barEngine As BarcodeEngine = New BarcodeEngine()
   Dim searchRect As Rectangle = New Rectangle(0, 0, 0, 0)
   Dim bar1d As Barcode1d = New Barcode1d()
   bar1d.Direction = BarcodeDirectionFlags.LeftToRight
   bar1d.Granularity = 9
   bar1d.MaximumLength = 3
   bar1d.MinimumLength = 1

   Try
      ' Try to read barcodes
      barEngine.Read(image, searchRect, BarcodeSearchTypeFlags.Barcode1dEan13, BarcodeUnit.ScanlinesPerPixels, BarcodeReadFlags.BlockSearch Or BarcodeReadFlags.Markers, 0, bar1d, Nothing, Nothing)
      BarcodeEngine.Shutdown()
   Catch ex As BarcodeException
      ' See if LEADTOOLS could not recognize this image format
      If ex.Code = BarcodeExceptionCode.Barcode1dLocked Then
         MessageBox.Show("You need to unlock barcode linear engine")
      Else
         ' Other LEADTOOLS Barcode error
         MessageBox.Show(String.Format("Could not read barcodes, Leadtools code: {0}" & Constants.vbLf & "Message: {1}", ex.Code, ex.Message))
      End If
   Catch ex As Exception
      ' Other errors
      MessageBox.Show(String.Format("Could not read barcodes {0}", ex.Message))
   End Try

   RasterCodecs.Shutdown()
End Sub
C#Copy Code
private void CodeExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   string fileName = LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif"; 
   RasterImage image = codecs.Load(fileName); 
 
   // Initialize linear barcodes 
   BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d); 
   BarcodeEngine barEngine = new BarcodeEngine(); 
   Rectangle searchRect = new Rectangle(0, 0, 0, 0); 
   Barcode1d bar1d = new Barcode1d(); 
   bar1d.Direction = BarcodeDirectionFlags.LeftToRight; 
   bar1d.Granularity = 9; 
   bar1d.MaximumLength = 3; 
   bar1d.MinimumLength = 1; 
 
   try 
   { 
      // Try to read barcodes 
      barEngine.Read(image, searchRect, BarcodeSearchTypeFlags.Barcode1dEan13, BarcodeUnit.ScanlinesPerPixels, BarcodeReadFlags.BlockSearch | BarcodeReadFlags.Markers, 0, bar1d, null, null); 
      BarcodeEngine.Shutdown(); 
   } 
   catch (BarcodeException ex) 
   { 
      // See if LEADTOOLS could not recognize this image format 
      if (ex.Code == BarcodeExceptionCode.Barcode1dLocked) 
         MessageBox.Show("You need to unlock barcode linear engine"); 
      else 
      { 
         // Other LEADTOOLS Barcode error 
         MessageBox.Show(string.Format("Could not read barcodes, Leadtools code: {0}\nMessage: {1}", ex.Code, ex.Message)); 
      } 
   } 
   catch (Exception ex) 
   { 
      // Other errors 
      MessageBox.Show(string.Format("Could not read barcodes {0}", ex.Message)); 
   } 
 
   RasterCodecs.Shutdown(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features