473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Click event gets lost when call MSGBOX in leave event

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
3 3809
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to...
1
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private void Button1_MouseUp(Object sender,...
7
by: Rich | last post by:
Hello, I have 10 textboxes on a form. I would like to validate text-data entry on each textbox. I was looking for a Form_Current event or Form_Change event but did not recognize any such...
3
by: David Kelly | last post by:
I am noticing a strange behaviour with the button Click event. A simple test case - a form with a textbox and a button. Attach the following two handlers. Private Sub TextBox1_Leave(ByVal...
12
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items...
0
by: Tom | last post by:
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...
4
by: Winista | last post by:
I have a page with bunch of user controls and standard controls on the page. And then I have a Button control on the page which is used to save the data on server side. All was working fine and...
2
by: Joergen Bech | last post by:
Hope someone has a solution or some suggestions for this. This cannot be right?!? Problem: I have multiple non-modal forms open at the same time. One or more of these forms have a...
1
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.