Jump to Content Jump to Navigation

BASIC keywords

These keywords will be familiar to anyone involved with programming in the last few decades. BASIC is responsible for the lasting popularity of quite a few of these commands and keywords, and their influence can also be seen in more recent languages like C. Visual BASIC differs from other BASIC languages in that it uses very few of these keywords, although several of them can be used optionally based on preference.

  • LET Command – assigns a value (which may be the result of an expression) to a variable.
  • DATA Statement – holds a list of values which are assigned sequentially using the READ Command.
  • IF … THEN … ELSE Statement – used to perform comparisons or make decisions.
  • FOR … NEXT Statement – repeat a section of code a given number of times. A variable that acts as a counter is available within the loop.
  • WHILE … WEND and REPEAT … UNTIL Commands – repeat a section of code while the specified condition is true. The condition may be evaluated before each iteration of the loop, or after.
  • GOTO Command – jumps to a numbered or labelled line in the program.
  • GOSUB Command – temporarily jumps to a numbered or labelled line, returning to the following line after encountering the RETURN Command. This is used to implement subroutines.
  • ON … GOTO/GOSUB Command – chooses where to jump based on the specified conditions. See Switch statement for other forms.
  • PRINT Statement – displays a message on the screen or other output device.
  • INPUT Statement – asks the user to enter the value of a variable. The statement may include a prompt message.
  • TAB or AT Function – sets the position where the next character will be shown on the screen or printed on paper.
  • REM (Remark) – holds a programmer’s comment; often used to give a title to the program and to help identify the purpose of a given section of code.