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

Problems with Leave event validation.

P: n/a
All.

I'm fairly new to VB.Net, and VB in general so please bear with me.

I have form with two or three controls that require validation on
exit. I have done this by using the "leave" event of the objects
conserned, it all works very well.

Except if the user clicks on the exit button whilst in one of these
fobjects/fields . Clicking the Exit button executes the validataion. I
just want the form to exit without executing the validation.

How do I achieve this?

Thanks in advance.

Rob_B.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Rob,

I had a similar problem exiting any form that required validation in any
way. Rulin Hong answered me with the code below. It's a bit cryptic
(including a typo or two), but it works fine.

Let me know if you can't follow it.

HTH,

Bernie Yaeger
---------------------
Hey Rulin,

Excellent code - I've been looking for this for some time! Tx
Bernie Yaeger

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
Add following code in winform:

Private NeedValidting As Boolean = True
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating If NeedValidting Then
'Do Validating
End If
End Sub

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = &H10 Then
NeedValidting = False
End If
MyBase.WndProc(m)
End Sub ----------------
"Rob Bradford" <ro**********@lvirgin.net> wrote in message
news:bn********************************@4ax.com... All.

I'm fairly new to VB.Net, and VB in general so please bear with me.

I have form with two or three controls that require validation on
exit. I have done this by using the "leave" event of the objects
conserned, it all works very well.

Except if the user clicks on the exit button whilst in one of these
fobjects/fields . Clicking the Exit button executes the validataion. I
just want the form to exit without executing the validation.

How do I achieve this?

Thanks in advance.

Rob_B.

Nov 21 '05 #2

P: n/a
Rob Bradford <ro**********@lvirgin.net>'s wild thoughts were
released on Sat, 25 Sep 2004 07:20:33 +0000 (UTC) bearing
the following fruit:
All.

I'm fairly new to VB.Net, and VB in general so please bear with me.

I have form with two or three controls that require validation on
exit. I have done this by using the "leave" event of the objects
conserned, it all works very well.

Except if the user clicks on the exit button whilst in one of these
fobjects/fields . Clicking the Exit button executes the validataion. I
just want the form to exit without executing the validation.

How do I achieve this?
May I suggest you change your code.

Don't validate each control in the way you are doing, it's a
PITA for keyboard users.

Write one validation routine and call it from the OK button.

Not only does it make maitenance of the validation easier,
it solves your problem and makes your application easier to
use.
Thanks in advance.

Rob_B.

Jan Hyde (VB MVP)

--
Too many square meals can lead to a round belly. (Jumble)

[Abolish the TV License - http://www.tvlicensing.biz/]

Nov 21 '05 #3

P: n/a
Thanks to everyone who replied, it was a great help.

On Sat, 25 Sep 2004 07:20:33 +0000 (UTC), Rob Bradford
<ro**********@lvirgin.net> wrote:
All.

I'm fairly new to VB.Net, and VB in general so please bear with me.

I have form with two or three controls that require validation on
exit. I have done this by using the "leave" event of the objects
conserned, it all works very well.

Except if the user clicks on the exit button whilst in one of these
fobjects/fields . Clicking the Exit button executes the validataion. I
just want the form to exit without executing the validation.

How do I achieve this?

Thanks in advance.

Rob_B.


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.