That's a term used for code that breaks easily whan anything is changed. For example, once you get into the loop, the only way to get out again is to cancel the program - not a very satisfactory user experience.Adding Cancel capability to the error boxes adds a lot of code and even more complexity. The Cancel button in the Input Box returns a "zero length string". Text = "5 grades entered" & vb New Line & "No more input allowed" End If End If input Grade. But if, for some reason, you have to use the Input Box, here's a followup article that explains how to solve one main problem.I haven't actually tried to write a loop like this since VB.But a zero length string is also returned if the user simply forgets to enter anything. NET where there are even more sophisticated ideas, the best way to improve this program is to simply get rid of the Input Box and loop. Focus() End Sub It's a minor point, but you might also keep in mind that the VB.There's a way to tell the difference, but it requires using unmanaged code. Use a simple Text Box to enter the data and use a Label to display messages. NET And Also and Or Else operators are "short circuit" operators.And you can end the program without completing the loop! Text = "Nothing entered" & vb New Line & "Please enter a grade" Else If Not Is Numeric(input Grade. Text = "Input is not a numeric grade" & vb New Line & "Please enter a numeric grade" Else If CDec(input Grade. Text = "Enter a grade between 0-100" Else Valid Grade Entry = True End If End Sub Private Sub btn Accept Grades_Click( By Val sender As System.
And for data validation, code a Validating event for the Text Box control. That means that if you have a whole list of validating conditions, you can code them as a whole series connected with these operators (with the most frequent hits first) and nothing below a validation test that fails will use any processing.
This puts validation into one self-contained block and data entry into a different one.