Results 1 to 5 of 5

Thread: [RESOLVED] Message box

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Resolved [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:
    1. If Me.File_Name.Text = "" Then
    2.             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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Message box

    Quote Originally Posted by jmcilhinney View Post
    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

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. If Me.File_Name.Text <> String.Empty OrElse
    2.    MessageBox.Show("No file has been selected.  Would you like to proceed?", _
    3.                    "Confirm", _
    4.                    MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
    5.     'Proceed
    6. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Message box

    Quote Originally Posted by jmcilhinney View Post
    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:
    1. If Me.File_Name.Text <> String.Empty OrElse
    2.    MessageBox.Show("No file has been selected.  Would you like to proceed?", _
    3.                    "Confirm", _
    4.                    MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then
    5.     'Proceed
    6. 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
  •  



Click Here to Expand Forum to Full Width