Structuring Your Code Logically

Before we leave the subject of control-flow statements, we need to mention something about the influence of programming style on your code. You have an enormous amount of freedom when writing VB code, but you should not let that freedom cause you to write messy code. As an example, let’s look at test grades again. We have already covered how to do averaging and number-to-letter conversion using a Select Case statement. However, suppose someone enters an invalid numeric grade in one of the text boxes, such as 789 or –1234? Validating the data entered in the text boxes will require adding some If statements before you attempt to average the grades. If any of the grades entered is not a valid numeric grade, you should ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.