The importance of indenting

It is important to indent in visual basic because it forms logical paths for the eye to follow when reviewing or debugging later on. Although it doesn't change how the program runs, it does help the programmer later when the code becomes more complex.
For example:
If optBeginner.Value = True Then
  If intGuess < intNumber Then
    lblRightWrong.ForeColor = QBColor(1)
    lblRightWrong.Caption = "You are wrong."
    lblLowHigh.Caption = "That guess was too low"
    lblToolow.Caption = lblToolow.Caption & " " & intGuess
    intCounter = intCounter + 1
    If intCounter = dblGuesses Then
      MsgBox "You are out of guesses. The game is over."
      cmdAsk.Visible = False
      cmdNew.Visible = True
      cmdHelp.Visible = True
      Exit Sub
    End If
  End If
End If

In this example it is very easy to line up the openings of a code (the If) and the end of a code (the end if).

Events are things that the user does. They include: clicking, double clicking, right clicking, typing, clicking and dragging.
Events cause the program to perform a function. These include making random numbers, mathematical functions, or making things move.
The code for generating a random number between 1 and 100 would look something like this:
intNumber=int(rnd * 100)+1
For the above code, it would also be necessary to put a randomize statement as part of the formload.
Mathematical functions work much like a calculator, with "/" dividing and "*" multiplying.
"If" statements are used so that the program will only do something if the properties are correct.
  "If...End If" would only perform the function in between if the properties of an object matched the requirements.
  "If...Else...End If" would perform the function included, but if the properties did not correspond, would do something else.
  "If...Elseif...Else...End if" would perform the original function if the properties corresponded, perform the second function if the second set corresponded (potentially there could be many more elseif's) and then the else would be performed if no other properties correspond.

Here is a list of qbasic colours.
Number Colour Number Colour
0 Black 8 Grey
1 Blue 9 Light Blue
2 Green 10 Light Green
3 Cyan 11 Light Cyan
4 Red 12 Light Red
5 Magenta 13 Light Magenta
6 Yellow 14 Light Yellow
7 White 15 Bright White


Back
Hosted by www.Geocities.ws

1