Error control
2 posts • Page 1 of 1
Error control
I need to control errors in a VB6 application to deliver my own errors to the user and avoid barcode activex error display and, specially, the unexpected end of my application.
It is specially important when changing symbology, as the message is changed to the symbology default message (btw, something not documented, it took me some time to realize), and I need to change it back to the original message, or, if that is not possible, display a warning message and undo the symbology change.
I couldn´t find any way to trap the error, and the VB6 sample doesn´t help.
Here is my code:
Private Sub Combo1_click()
Dim simbologiaactual As Integer
Dim mensajeactual As String
On Error GoTo errorsimbologia
simbologiaactual = MrvBarcode1.Symbology
mensajeactual = MrvBarcode1.message
Select Case Combo1.ListIndex
Case 0: MrvBarcode1.Symbology = mbxCode39
Case 1: MrvBarcode1.Symbology = mbxCode39_Full_ASCII
Case 2: MrvBarcode1.Symbology = mbxCode39_HIBC
Case 3: MrvBarcode1.Symbology = mbxCodaBar
Case 4: MrvBarcode1.Symbology = mbxCode93
Case 5: MrvBarcode1.Symbology = mbxCode128
Case 6: MrvBarcode1.Symbology = mbxUCC_EAN_128
Case 7: MrvBarcode1.Symbology = mbxInterleaved_2of5
Case 8: MrvBarcode1.Symbology = mbxUPC_A
Case 9: MrvBarcode1.Symbology = mbxUPC_E
Case 10: MrvBarcode1.Symbology = mbxEAN_13
Case 11: MrvBarcode1.Symbology = mbxEAN_8
Case 12: MrvBarcode1.Symbology = mbxBookland
Case 13: MrvBarcode1.Symbology = mbxTelepen
Case 14: MrvBarcode1.Symbology = mbxTelepenNumeric
Case 15: MrvBarcode1.Symbology = mbxPostnet
Case 16: MrvBarcode1.Symbology = mbxPlanet
Case 17: MrvBarcode1.Symbology = mbxRoyalMail
Case 18: MrvBarcode1.Symbology = mbxMSI_Plessey
Case 19: MrvBarcode1.Symbology = mbxCode25
Case 20: MrvBarcode1.Symbology = mbxCode11
Case 21: MrvBarcode1.Symbology = mbxPDF417
Case 22: MrvBarcode1.Symbology = mbxDataMatrix
Case 23: MrvBarcode1.Symbology = mbxMaxiCode
End Select
MrvBarcode1.message = lineatexto2
simbologia = MrvBarcode1.Symbology
grabarcambios = True
Exit Sub
errorsimbologia:
MsgBox ("Tipo de código de barras incorrecto para el texto introducido")
MrvBarcode1.Symbology = simbologiaactual
MrvBarcode1.message = mensajeactual
End Sub
The "On Error GoTo errorsimbologia" instruction is not trapping the error, when the instruction "MrvBarcode1.message = lineatexto2" gets processed a run time error from the activeX control is displayed and the application has to end.
I would appreciate any help. Thanks in advance
Antonio López
PS. I checked the new DLL component, and it seems that the return execution code would allow to trap the error but I already buyed the ActiveX control severals month ago
It is specially important when changing symbology, as the message is changed to the symbology default message (btw, something not documented, it took me some time to realize), and I need to change it back to the original message, or, if that is not possible, display a warning message and undo the symbology change.
I couldn´t find any way to trap the error, and the VB6 sample doesn´t help.
Here is my code:
Private Sub Combo1_click()
Dim simbologiaactual As Integer
Dim mensajeactual As String
On Error GoTo errorsimbologia
simbologiaactual = MrvBarcode1.Symbology
mensajeactual = MrvBarcode1.message
Select Case Combo1.ListIndex
Case 0: MrvBarcode1.Symbology = mbxCode39
Case 1: MrvBarcode1.Symbology = mbxCode39_Full_ASCII
Case 2: MrvBarcode1.Symbology = mbxCode39_HIBC
Case 3: MrvBarcode1.Symbology = mbxCodaBar
Case 4: MrvBarcode1.Symbology = mbxCode93
Case 5: MrvBarcode1.Symbology = mbxCode128
Case 6: MrvBarcode1.Symbology = mbxUCC_EAN_128
Case 7: MrvBarcode1.Symbology = mbxInterleaved_2of5
Case 8: MrvBarcode1.Symbology = mbxUPC_A
Case 9: MrvBarcode1.Symbology = mbxUPC_E
Case 10: MrvBarcode1.Symbology = mbxEAN_13
Case 11: MrvBarcode1.Symbology = mbxEAN_8
Case 12: MrvBarcode1.Symbology = mbxBookland
Case 13: MrvBarcode1.Symbology = mbxTelepen
Case 14: MrvBarcode1.Symbology = mbxTelepenNumeric
Case 15: MrvBarcode1.Symbology = mbxPostnet
Case 16: MrvBarcode1.Symbology = mbxPlanet
Case 17: MrvBarcode1.Symbology = mbxRoyalMail
Case 18: MrvBarcode1.Symbology = mbxMSI_Plessey
Case 19: MrvBarcode1.Symbology = mbxCode25
Case 20: MrvBarcode1.Symbology = mbxCode11
Case 21: MrvBarcode1.Symbology = mbxPDF417
Case 22: MrvBarcode1.Symbology = mbxDataMatrix
Case 23: MrvBarcode1.Symbology = mbxMaxiCode
End Select
MrvBarcode1.message = lineatexto2
simbologia = MrvBarcode1.Symbology
grabarcambios = True
Exit Sub
errorsimbologia:
MsgBox ("Tipo de código de barras incorrecto para el texto introducido")
MrvBarcode1.Symbology = simbologiaactual
MrvBarcode1.message = mensajeactual
End Sub
The "On Error GoTo errorsimbologia" instruction is not trapping the error, when the instruction "MrvBarcode1.message = lineatexto2" gets processed a run time error from the activeX control is displayed and the application has to end.
I would appreciate any help. Thanks in advance
Antonio López
PS. I checked the new DLL component, and it seems that the return execution code would allow to trap the error but I already buyed the ActiveX control severals month ago
- alopez(Legacy member)
Re: Error control
Try the code below. It worked on my machine -
Private Sub Combo_Symbology_Click()
'save the symbology
Dim barcode_format_save As SymbologyEnum
barcode_format_save = MrvBarcode1.Symbology
Select Case Combo_Symbology.ListIndex
Case 0: MrvBarcode1.Symbology = mbxCode39
Case 1: MrvBarcode1.Symbology = mbxCode39_Full_ASCII
Case 2: MrvBarcode1.Symbology = mbxCode39_HIBC
Case 3: MrvBarcode1.Symbology = mbxCodaBar
Case 4: MrvBarcode1.Symbology = mbxCode93
Case 5: MrvBarcode1.Symbology = mbxCode128
Case 6: MrvBarcode1.Symbology = mbxUCC_EAN_128
Case 7: MrvBarcode1.Symbology = mbxInterleaved_2of5
Case 8: MrvBarcode1.Symbology = mbxUPC_A
Case 9: MrvBarcode1.Symbology = mbxUPC_E
Case 10: MrvBarcode1.Symbology = mbxEAN_13
Case 11: MrvBarcode1.Symbology = mbxEAN_8
Case 12: MrvBarcode1.Symbology = mbxBookland
Case 13: MrvBarcode1.Symbology = mbxTelepen
Case 14: MrvBarcode1.Symbology = mbxTelepenNumeric
Case 15: MrvBarcode1.Symbology = mbxPostnet
Case 16: MrvBarcode1.Symbology = mbxPlanet
Case 17: MrvBarcode1.Symbology = mbxRoyalMail
Case 18: MrvBarcode1.Symbology = mbxMSI_Plessey
Case 19: MrvBarcode1.Symbology = mbxCode25
Case 20: MrvBarcode1.Symbology = mbxCode11
Case 21: MrvBarcode1.Symbology = mbxPDF417
Case 22: MrvBarcode1.Symbology = mbxDataMatrix
Case 23: MrvBarcode1.Symbology = mbxMaxiCode
End Select
'save the text
Dim strMsgSave As String
strMsgSave = Text_Message.Text
On Error GoTo Reset_symbology
MrvBarcode1.message = strMsgSave
Exit Sub
Reset_symbology:
MsgBox "Can not encode the text with selected symbology"
MrvBarcode1.Symbology = barcode_format_save
MrvBarcode1.message = strMsgSave
End Sub
Private Sub Combo_Symbology_Click()
'save the symbology
Dim barcode_format_save As SymbologyEnum
barcode_format_save = MrvBarcode1.Symbology
Select Case Combo_Symbology.ListIndex
Case 0: MrvBarcode1.Symbology = mbxCode39
Case 1: MrvBarcode1.Symbology = mbxCode39_Full_ASCII
Case 2: MrvBarcode1.Symbology = mbxCode39_HIBC
Case 3: MrvBarcode1.Symbology = mbxCodaBar
Case 4: MrvBarcode1.Symbology = mbxCode93
Case 5: MrvBarcode1.Symbology = mbxCode128
Case 6: MrvBarcode1.Symbology = mbxUCC_EAN_128
Case 7: MrvBarcode1.Symbology = mbxInterleaved_2of5
Case 8: MrvBarcode1.Symbology = mbxUPC_A
Case 9: MrvBarcode1.Symbology = mbxUPC_E
Case 10: MrvBarcode1.Symbology = mbxEAN_13
Case 11: MrvBarcode1.Symbology = mbxEAN_8
Case 12: MrvBarcode1.Symbology = mbxBookland
Case 13: MrvBarcode1.Symbology = mbxTelepen
Case 14: MrvBarcode1.Symbology = mbxTelepenNumeric
Case 15: MrvBarcode1.Symbology = mbxPostnet
Case 16: MrvBarcode1.Symbology = mbxPlanet
Case 17: MrvBarcode1.Symbology = mbxRoyalMail
Case 18: MrvBarcode1.Symbology = mbxMSI_Plessey
Case 19: MrvBarcode1.Symbology = mbxCode25
Case 20: MrvBarcode1.Symbology = mbxCode11
Case 21: MrvBarcode1.Symbology = mbxPDF417
Case 22: MrvBarcode1.Symbology = mbxDataMatrix
Case 23: MrvBarcode1.Symbology = mbxMaxiCode
End Select
'save the text
Dim strMsgSave As String
strMsgSave = Text_Message.Text
On Error GoTo Reset_symbology
MrvBarcode1.message = strMsgSave
Exit Sub
Reset_symbology:
MsgBox "Can not encode the text with selected symbology"
MrvBarcode1.Symbology = barcode_format_save
MrvBarcode1.message = strMsgSave
End Sub
- glitch (legacy member)
2 posts • Page 1 of 1
Return to Barcode ActiveX Control
Who is online
Users browsing this forum: No registered users and 0 guests