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




Gets or sets the the code 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;}
Managed Extensions for C++ 
public: __property BarcodeExceptionCode get_Code();
public: __property void set_Code( 
   BarcodeExceptionCode value
);
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("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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; 
 
   RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\barcode1.tif"); 
 
   // 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: Raster Pro/Document/Medical Features