473,320 Members | 1,883 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,320 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 3804
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.