|
-
Nov 25th, 2009, 01:55 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Message box
How do I get message box to stop loading new form
I have the following code on a button that loads new form
h Code:
If Me.File_Name.Text = "" Then
MessageBox.Show("No DataFile Has Been Selected", "Please Select a DataFile", MessageBoxButtons.OK)
I want to stop loading the form is the message box appears
Thanks
-
Nov 25th, 2009, 02:02 AM
#2
Re: Message box
The MessageBox doesn't do anything but display the message. If you don't want to show the form then don't call its Show method. Probably you'd want to add an Else block to your If statement and show the form there. That way, either the MessageBox will be shown or the form will, but never both.
-
Nov 25th, 2009, 02:11 AM
#3
Thread Starter
Frenzied Member
Re: Message box
 Originally Posted by jmcilhinney
The MessageBox doesn't do anything but display the message. If you don't want to show the form then don't call its Show method. Probably you'd want to add an Else block to your If statement and show the form there. That way, either the MessageBox will be shown or the form will, but never both.
Thank you that works fine for my purposes, out of curisoity i thought read in the documentation about message box have different buttons that could be assigned integer values ?
abort cancel retry
I wasnt able to totally grasp it, but will re read, if you could share any insight It would appreciated
Thanks again
-
Nov 25th, 2009, 02:25 AM
#4
Re: Message box
The message in your MessageBox doesn't indicate that you're giving the user a choice; just that you're notifying them of something. If you want to provide options then your message should indicate that. You can then use the MessageBoxButtons enumeration to specify what buttons to display, e.g.
vb.net Code:
If Me.File_Name.Text <> String.Empty OrElse
MessageBox.Show("No file has been selected. Would you like to proceed?", _
"Confirm", _
MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
'Proceed
End If
Now the code will proceed if the TextBox is not empty or if the user clicks the OK button on the MessageBox. Note that the MessageBox is only displayed if the TextBox is empty.
-
Nov 25th, 2009, 02:31 AM
#5
Thread Starter
Frenzied Member
Re: Message box
 Originally Posted by jmcilhinney
The message in your MessageBox doesn't indicate that you're giving the user a choice; just that you're notifying them of something. If you want to provide options then your message should indicate that. You can then use the MessageBoxButtons enumeration to specify what buttons to display, e.g.
vb.net Code:
If Me.File_Name.Text <> String.Empty OrElse
MessageBox.Show("No file has been selected. Would you like to proceed?", _
"Confirm", _
MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
'Proceed
End If
Now the code will proceed if the TextBox is not empty or if the user clicks the OK button on the MessageBox. Note that the MessageBox is only displayed if the TextBox is empty.
ok got it thanks, you example helped me see it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|