Imports Leadtools
Imports Leadtools.Twain
Public Sub SetCodeMessageExample()
' Get the initial FileFormat message
Dim code As TwainExceptionCode = TwainExceptionCode.StopScan
Dim message As String = TwainException.GetCodeMessage(code)
MessageBox.Show(String.Format("Code: {0}, message: {1}", code, message))
' make sure that this message is used now
Try
Throw New TwainException(code)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
' change this message to a custom one
TwainException.SetCodeMessage(code, "My new message")
' make sure that this new message is used now
Try
Throw New TwainException(code)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
using Leadtools;
using Leadtools.Twain;
public void SetCodeMessageExample()
{
// Get the initial FileFormat message
TwainExceptionCode code = TwainExceptionCode.StopScan;
string message = TwainException.GetCodeMessage(code);
MessageBox.Show(string.Format("Code: {0}, message: {1}", code, message));
// make sure that this message is used now
try
{
throw new TwainException(code);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
// change this message to a custom one
TwainException.SetCodeMessage(code, "My new message");
// make sure that this new message is used now
try
{
throw new TwainException(code);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}