exception handling

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2006
Posts: 1,169
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Solved Threads: 9
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

exception handling

 
0
  #1
Sep 16th, 2007
is there a way to make this:
  1. If dvdRadioButton.Checked = False And vhsRadioButton.Checked = False Then
  2. MessageBox.Show("Format not specified", "Unspecified format", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
  3. dvdRadioButton.Focus()
  4. End If
  5.  
  6. If movieTitleTextBox.Text = "" Then
  7. MessageBox.Show("Movie title not entered", "Movie Title", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
  8. movieTitleTextBox.Focus()
  9. 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!
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.

-Edsger Dijkstra
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 38
Reputation: matale is an unknown quantity at this point 
Solved Threads: 1
matale matale is offline Offline
Light Poster

Re: exception handling

 
0
  #2
Sep 17th, 2007
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
My current Project www.footystat.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC