By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,967 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,967 IT Pros & Developers. It's quick & easy.

Click event gets lost when call MSGBOX in leave event

P: n/a
Tom
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRate_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtIDiscountRate.Leave
If txtIDiscountRate.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKCancel) _
= MsgBoxResult.Cancel Then
'txtIDiscountRate.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.LostFocus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRate_TextChanged(ByVal sender ..., but you use
'Handles TextBox.LostFocus

The above is a mistake.

Remember to use 'MessageBox.Show(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRate_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtIDiscountRate.Leave
If txtIDiscountRate.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKCancel) _
= MsgBoxResult.Cancel Then
'txtIDiscountRate.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #2

P: n/a
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.LostFocus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRate_TextChanged(ByVal sender ..., but you use
'Handles TextBox.LostFocus

The above is a mistake.

Remember to use 'MessageBox.Show(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRate_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtIDiscountRate.Leave
If txtIDiscountRate.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKCancel) _
= MsgBoxResult.Cancel Then
'txtIDiscountRate.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #3

P: n/a
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.LostFocus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRate_TextChanged(ByVal sender ..., but you use
'Handles TextBox.LostFocus

The above is a mistake.

Remember to use 'MessageBox.Show(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRate_TextChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
txtIDiscountRate.Leave
If txtIDiscountRate.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKCancel) _
= MsgBoxResult.Cancel Then
'txtIDiscountRate.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.