Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 3rd, 2006, 6:25 AM   #1
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 47
Rep Power: 0 Robocop is on a distinguished road
VB If Statement Help

I just want to make these statements so that when the if is true, the message box is shown and the form is not closed. If the required fields are blank, then the form should not close, but it is closing after you click the message box. Can anybody help me with this?

Quote:
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
If Me.edit_type.Text = "" Or Me.editname.Text = "" Then
'MessageBox.Show("Please fill the required fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
'Update the Dataset
Me.UpdateDataSet()
End If
End Sub
Robocop is offline   Reply With Quote
Old Dec 3rd, 2006, 7:20 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
A quick google for "vb onclose event" leads me to think you can just put in
that setting e.Cancel to True cancels the close.
The Dark is offline   Reply With Quote
Old Dec 3rd, 2006, 10:56 PM   #3
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
one thing I'd suggest, not that you have to is instead of Me.edit_type.Text = "" I would use Me.edit_type.Text = nothing. To me that just seems better, don't know how others would feel. Either way works fine, I just see "Nothing" neater than ""
PhilBon is offline   Reply With Quote
Old Dec 4th, 2006, 2:40 PM   #4
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 47
Rep Power: 0 Robocop is on a distinguished road
Quote:
Originally Posted by The Dark View Post
A quick google for "vb onclose event" leads me to think you can just put in
that setting e.Cancel to True cancels the close.
Thanks! it worked great!

Quote:
Originally Posted by PhilBon
one thing I'd suggest, not that you have to is instead of Me.edit_type.Text = "" I would use Me.edit_type.Text = nothing. To me that just seems better, don't know how others would feel. Either way works fine, I just see "Nothing" neater than ""
Nice idea.
Robocop is offline   Reply With Quote
Old Dec 5th, 2006, 4:21 PM   #5
BlackDal
Newbie
 
Join Date: Feb 2006
Posts: 12
Rep Power: 0 BlackDal is on a distinguished road
its better write this code into Form.Closing routine
BlackDal is offline   Reply With Quote
Old Dec 5th, 2006, 7:35 PM   #6
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 47
Rep Power: 0 Robocop is on a distinguished road
Quote:
Originally Posted by BlackDal View Post
its better write this code into Form.Closing routine
That's true, "e.Cancel" didn't work with Form.Closed anyways.
Robocop is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
switch statement NightShade01 Java 5 Jan 11th, 2007 2:40 AM
SQL Select Statement Performance King Other Scripting Languages 6 Dec 1st, 2006 5:12 PM
statement with no effect? iradic C 10 Oct 23rd, 2006 1:22 PM
Why did %S break my if statement? somehollis Python 3 Jun 22nd, 2006 8:49 PM
Trouble with a swith statement cjaime C 10 Nov 8th, 2005 11:09 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC