Link to home
Start Free TrialLog in
Avatar of xxdesmus
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.SelectedItem = Nothing) Then
                MessageBox.Show("You did not select a Proc type.")
                comboFilled = False
            Else
                myNewBox.Proc = Me.newProcType.SelectedItem.ToString()
                comboFilled = True
            End If

            If (Me.newProcSpeed.SelectedItem = Nothing) Then
                MessageBox.Show("You did not select a Proc speed.")
                comboFilled = False
            Else
                myNewBox.ProcSpeed = Me.newProcSpeed.SelectedItem.ToString()
                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.SelectedItem = Nothing) Then
                MessageBox.Show("You did not select a Hard drive.")
                comboFilled = False
            Else
                myNewBox.HardDrive = Me.newHardDrive.SelectedItem.ToString()
                comboFilled = True
            End If

            If (Me.newMonitor.SelectedItem = 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.Display())
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xxdesmus
xxdesmus

ASKER

Perfect! Thank you for the very prompt assistance. ...I was pretty sure it was something obvious, but I am still a beginning in terms of learning VB. I appreciate the help.
Not a problem, glad I was able to help. ;=)