xxdesmus
asked on
Escape while loop, then re-run while loop
I am in the process of learning Visual Basic (for work), and I am creating a sample application to test my knowledge so far... It's a simple application with 5 combo boxes that the user can select certain features of their computer, and then this information will be displayed back to the user.
The problem: I am trying to add some error checking into the application, such that if a combo box is empty it will prompt the user, and then give them a chance to try again...all combo boxes must be filled out before the pop up window will display with the computer info they entered.
What it's currently doing: it's stuck in the while loop after it hits the comboFilled = False...
What I think I need to do: I need to break out of the while loop to get them a chance to re-enter info in the combo box. They would then click on "Submit" again to fire off the while loop error check.
This is what I have so far... check runs after they click "Submit":
' ////////////////////////// ////////// ////////// ////////// //////
' On Click of the "submit" button check if combo boxes are blank
' \\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\
Dim comboFilled As Boolean
While comboFilled = False
If (Me.newProcType.SelectedIt em = Nothing) Then
MessageBox.Show("You did not select a Proc type.")
comboFilled = False
Else
myNewBox.Proc = Me.newProcType.SelectedIte m.ToString ()
comboFilled = True
End If
If (Me.newProcSpeed.SelectedI tem = Nothing) Then
MessageBox.Show("You did not select a Proc speed.")
comboFilled = False
Else
myNewBox.ProcSpeed = Me.newProcSpeed.SelectedIt em.ToStrin g()
comboFilled = True
End If
If (Me.newMemory.SelectedItem = Nothing) Then
MessageBox.Show("You did not select any Memory.")
comboFilled = False
Else
myNewBox.Memory = Me.newMemory.SelectedItem. ToString()
comboFilled = True
End If
If (Me.newHardDrive.SelectedI tem = Nothing) Then
MessageBox.Show("You did not select a Hard drive.")
comboFilled = False
Else
myNewBox.HardDrive = Me.newHardDrive.SelectedIt em.ToStrin g()
comboFilled = True
End If
If (Me.newMonitor.SelectedIte m = Nothing) Then
MessageBox.Show("You did not select a Monitor.")
comboFilled = False
Else
myNewBox.Monitor = Me.newMonitor.SelectedItem .ToString( )
comboFilled = True
End If
End While
' ////////////////////////// ////////// ////////// ////////// ////////// //////
' If the combo boxes are filled then continue...which pops up a message with the computer info.
' \\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\\\\\ \\\\\\
MessageBox.Show(myNewBox.D isplay())
The problem: I am trying to add some error checking into the application, such that if a combo box is empty it will prompt the user, and then give them a chance to try again...all combo boxes must be filled out before the pop up window will display with the computer info they entered.
What it's currently doing: it's stuck in the while loop after it hits the comboFilled = False...
What I think I need to do: I need to break out of the while loop to get them a chance to re-enter info in the combo box. They would then click on "Submit" again to fire off the while loop error check.
This is what I have so far... check runs after they click "Submit":
' //////////////////////////
' On Click of the "submit" button check if combo boxes are blank
' \\\\\\\\\\\\\\\\\\\\\\\\\\
Dim comboFilled As Boolean
While comboFilled = False
If (Me.newProcType.SelectedIt
MessageBox.Show("You did not select a Proc type.")
comboFilled = False
Else
myNewBox.Proc = Me.newProcType.SelectedIte
comboFilled = True
End If
If (Me.newProcSpeed.SelectedI
MessageBox.Show("You did not select a Proc speed.")
comboFilled = False
Else
myNewBox.ProcSpeed = Me.newProcSpeed.SelectedIt
comboFilled = True
End If
If (Me.newMemory.SelectedItem
MessageBox.Show("You did not select any Memory.")
comboFilled = False
Else
myNewBox.Memory = Me.newMemory.SelectedItem.
comboFilled = True
End If
If (Me.newHardDrive.SelectedI
MessageBox.Show("You did not select a Hard drive.")
comboFilled = False
Else
myNewBox.HardDrive = Me.newHardDrive.SelectedIt
comboFilled = True
End If
If (Me.newMonitor.SelectedIte
MessageBox.Show("You did not select a Monitor.")
comboFilled = False
Else
myNewBox.Monitor = Me.newMonitor.SelectedItem
comboFilled = True
End If
End While
' //////////////////////////
' If the combo boxes are filled then continue...which pops up a message with the computer info.
' \\\\\\\\\\\\\\\\\\\\\\\\\\
MessageBox.Show(myNewBox.D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not a problem, glad I was able to help. ;=)
ASKER