

Retrieving keyboard input from the user
One way to receive input from the keyboard is with the INPUT command. The INPUT command allows the user to enter either a string or a number, which is then stored in a variable.
When this program is executed, the INPUT command displays a question mark, followed by a blinking cursor. And when you enter text, the program stores that text into the variable data$, which is printed to the screen.
TIP: If you place a string and a semi-colon between INPUT and the variable, the program will print the string.
INPUT "Enter some text:"; data$
|
To receive a number, use a non-string variable.
INPUT number
PRINT number
If you enter text instead of a number, the QBasic interpreter displays an error message ("Redo from start").
Below is another example of the INPUT command:
PRINT "Enter some text:"
INPUT text$
PRINT "Now enter a number:"
INPUT num
PRINT text$
PRINT num
TIP: You can have the question mark displayed on the previous line by using a semi-colon.
PRINT "Enter some text:";
INPUT text$
|
Feel free to distribute this tutorial, upload it to your website, link to it from your site, etc.
http://www.geocities.com/progsharehouse/qbtutor
Mirror: http://development.freeservers.com/qbtutor
|