0

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!

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by matale
0

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:(

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.