7.7. Erorr Handling

Not all functions succeed unconditionally. You should always check the return value for errors when working with the program.

Barcode DLL reports two kinds of errors - operational errors and encoding errors. They are handled in different ways.

Operational errors occur when an operation fails or a property is set to an invalid value. The error is reported as returned value of the function. The error value is expressed in a 32-bit integer form, very similiar to the HRESULT error code in the COM world. Consequently you can use SUCCEEDED and FAILED macros to tell if the operation succeeds or fails.

For a list of applicable error codes, refer to the Chapter 9, Error Handling.

When error happens, you can use GetLastBarcodeErrorMessage to retrieve the reason, as demonstrated by the VB code below:

Dim rc As Long
rc=put_Message(handle, "ABCD123")
If ( rc < 0 ) Then
	GetLastBarcodeErrorMessage(barcode_object_handle, strError)
	MsgBox strError
End IF