Hi folks,
I don't know if anyone has seen this bug.
If you place a "Messagebox.show" statement for a message in the lostfocus event of a combobox/textbox, the damn message will popup FOREVER when exiting out of it. It won't let you exit the combobox/textbox. An infinite loop!
Please try it and see it for yourself. Please let me know if there a fix for this. I gave up. Spent 2 hours debugging it but no luck.
In case you are curious, below is my code. It is simple. Nothing fancy.
Cheers,
blumonde
PrivateSub txDID_LostFocus(ByVal sender AsObject, ByVal e As System.EventArgs) Handles txDID.LostFocus
If txDID.Text.Trim = "" Then Exit Sub
If Microsoft.VisualBasic.Left(txDID.Text.Trim, 1) = """" Then' Strip out quotes
txDID.Text = txDID.Text.Trim.Substring(1)
EndIf
If Microsoft.VisualBasic.Right(txDID.Text.Trim, 1) = """" Then' Strip out quotes
txDID.Text = txDID.Text.Trim.Substring(0, 5)
EndIf
If Not IsNumeric(txDID.Text.Trim) And txDID.Text <> "" Then
MessageBox.Show("DID should be numeric. Please re-enter", "New DID Info.", MessageBoxButtons.OK, MessageBoxIcon.Information)
ExitSub
EndIf
sStoreDid = Me.txDID.Text.Trim ' Store it so it can be used for the default
EndSub
I don't know if anyone has seen this bug.
If you place a "Messagebox.show" statement for a message in the lostfocus event of a combobox/textbox, the damn message will popup FOREVER when exiting out of it. It won't let you exit the combobox/textbox. An infinite loop!
Please try it and see it for yourself. Please let me know if there a fix for this. I gave up. Spent 2 hours debugging it but no luck.
In case you are curious, below is my code. It is simple. Nothing fancy.
Cheers,
blumonde
PrivateSub txDID_LostFocus(ByVal sender AsObject, ByVal e As System.EventArgs) Handles txDID.LostFocus
If txDID.Text.Trim = "" Then Exit Sub
If Microsoft.VisualBasic.Left(txDID.Text.Trim, 1) = """" Then' Strip out quotes
txDID.Text = txDID.Text.Trim.Substring(1)
EndIf
If Microsoft.VisualBasic.Right(txDID.Text.Trim, 1) = """" Then' Strip out quotes
txDID.Text = txDID.Text.Trim.Substring(0, 5)
EndIf
If Not IsNumeric(txDID.Text.Trim) And txDID.Text <> "" Then
MessageBox.Show("DID should be numeric. Please re-enter", "New DID Info.", MessageBoxButtons.OK, MessageBoxIcon.Information)
ExitSub
EndIf
sStoreDid = Me.txDID.Text.Trim ' Store it so it can be used for the default
EndSub
Last edited: