954,219 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

exception handling

is there a way to make this:

If dvdRadioButton.Checked = False And vhsRadioButton.Checked = False Then
            MessageBox.Show("Format not specified", "Unspecified format", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
            dvdRadioButton.Focus()
        End If

        If movieTitleTextBox.Text = "" Then
            MessageBox.Show("Movie title not entered", "Movie Title", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
            movieTitleTextBox.Focus()
        End If

throw a single error message instead of two, one right after the other (without using the if construct)?

I read something about add handles or something? Any help is appreciated!

Duki
Nearly a Posting Virtuoso
1,475 posts since Jun 2006
Reputation Points: 817
Solved Threads: 32
 

You could have a boolean inside the first If (boolFormat) which is set to true if the radio buttons are not checked,
and then inside the second If another boolean (boolMovieTitle) which is set to true if the movieTitleBox is empty.

Then you put other Ifs to check which of the booleans are set to true and display an individual error or both errors in the same box

e.g
If(boolFormat==true && boolMovietitle==true)
{
//display a compined error msg box
}
elseif (boolFormat==true &&boolMovieTitle==false)
{
//display Format error msg only
}
elseif (booolMovieTitle == true && boolFormat==false)
{
//display Title error msg only
}

Some of the syntax might be wrong, its been a while:(

matale
Light Poster
38 posts since May 2007
Reputation Points: 22
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You