Shock Level: VB Lord

 Registered: 30-03-2003 Posts: 150
|
Re: Control Structures
Its all very logical...Basic was written so that any person could see the logic behind the commands.
im going to type the commands in caps, and the rest will be just normal english, then I will give a more accurate code example:
(this is an expanded version, there is a simpler type)
IF im hungry
THEN
eat:drink:sleep
ELSE IF im too tired
THEN sleep
ELSE do nothing much..
END IF
(the simpler type, using basic code)
IF a=1 THEN BEEP else msgbox$ "a is not 1!!!'
the DO is a loop type:
a = 0
DO WHILE a < 5
a = a + 1:debug.? a
WEND
(youll get this in debug:
1
2
3
4
5)
the while parrameter can be removed...so that it will loop infinitely (this is very usefull for many game types and basic utilities). WEND just means go back to the DO, and check for the while parameter if its either true or false.
UNTIL parameter is just what its word implies...does something untill something else is true.
theres also the FOR:NEXT while is my personal favorite (:grin .
FOR x = 1 to 5
debug.? x
NEXT x
(youll get this in debug:
1
2
3
4
5)
hope this helps any...
|