For all programs written in this class must adhere to programming the following guidelines. Points will be deducted if they do not. I will update the programming guidelines as new concepts are introduced. New guidelines will appear in red. Once a new guideline has been introduced all future programs must adhere to it.
Precede and follow each Do…Loop block with a blank line.
Indent all statements inside loops
Align the beginning clause of the loop with the ending clause of the loop
Precede and follow each For….Next block with a blank line.
Do not modify the value of the Counter Control variable used in a For..Next statement while inside the loop.
Use For..Next loops for counter controlled loops only. (That does NOT mean you cannot use a different looping tool for situations that require a counter controlled loop. Only that the only appropriate use of the For..Next loop is a counter controlled loop)
For solutions you create from scratch - name your solution using the following convention - Your initials followed by an underscore and the lab number. For example - khc_Lab0
Name all controls using appropriate lowercase prefixes (prefix for Textbox – txt, Labels – lbl, command buttons – btn) followed by a descriptive word that begins with a capital letter like btnCalculate or lblMessge. Spaces are not allowed in identifiers.
Add comment lines (use apostrophes) at the top of your code window (in the declarations section) with your name and a description of the program. All comments will appear in green font. For example
‘Author: Kari Couch
‘Lab 1: The purpose of this lab is to declare variables, assign
them values, and display them in a label.
Group together like or related statements
Separate each group of like or related statements with a blank line
Use the concatenation operator & to create a string from two or more operand.
Use the continuation operator _ to continue long statement from one line to the next. Use continuation so that you can see all the code on the screen without scrolling to the right. Break lines at logical points.
Indent lines that are continued from the previous line.
Turn Option Strict On
Use methods of Convert to explicitly cast data types to the desired/required data type.
Use IsNumeric() to validate all numeric input
Make sure no output is displayed when input is determined to be invalid. In other words clear output labels when input is invalid.
Assign descriptive text to all appropriate visible controls.
Always include your name in the Form's title bar (Text property).
The design of all forms must be simple, intuitive, organized, and professional.
Always make sure an appropriate control has focus when your program loads
Always make sure focus travels logically through your form
Set focus back to the text box related to the command button after any output is displayed. If more than one text box is related set Focus to the first text box.
Always select the contents of the textbox when it receives focus.
Format all numbers appropriately when displayed in the labels.
Declare all variables in procedures when possible.
Group all declaration statements for procedural variables at the top of procedures.
Use standard prefixes for all variables
Use descriptive names for all variables
Use upper and lower case with purpose.
Declare only one variable per line
Use numeric variables for data that represents a quantity of something.
Only assign numeric data to numeric variables/properties and string data to string variables/properties.
Limit the scope of variables to the smallest possible range.
If a variable is needed only within one procedure it should be declared at procedural level.
If a variable is needed only within one procedure but must retain pervious value it should be declared at procedural level with the Static statement
If a variable is needed is needed by more than one procedure within the Form class you may declare it at Class level.
Do NOT do any numeric operations with controls.
Never store the result of a numeric operation directly in a control. Use variables instead.
Always use parenthesis to clarify expressions with multiple operators.
Always test divisors for zero value before a dividing.
Use block If statements
Code the Else statement on a line by it self.
Precede and follow each If statement block with a blank line.
Compare string operands only to string operands and numeric operands only to numeric operands.
Use .ToUpper or .ToLower methods or UCase( ) or LCase( ) functions when comparing string data if the comparison is not suppose to be case sensitive.
Do not nest If statements more than 3 deep.
Always use parenthesis to clarify compound conditions.
Limit the use of the logical operator NOT.
Always make the Test Expression and Expression List the same data type.
Use general procedures to break complex sections of code into smaller more manageable pieces and to prevent very long procedures.
If an If statement become nested too deeply consider moving some of the code into a general procedure
Whenever 3 or more statements are repeated in your program consider using a general procedure.
Give your procedures names that are descriptive. A good rule to follow is the verb-noun or verb-adjective-noun guideline. If you cannot describe the purpose of the procedure in three words you consider breaking the procedure into smaller procedures.
When passing arguments to procedures explicitly state ByRef or ByVal