: my friend is programming in basic and i want to see a code. im wondering how it looks....lol
: by the way, i can program in c++ a bit...
Is he using QBASIC or Visual Basic? They work very differently, but the root language is the same.
The major QBASIC commands include:
' REM or ' is what's used to add a comment.
' There is no closing comment, it just continues to the end of the line.
' There is also no end-of-operation symbol like in c++ (;)
' instead you just add a carriage return (ENTER) to go to the next command.
x = 1 'Sets x equal to 1
x = x + 1 'Sets x equal to x + 1
x = 4
PRINT x 'PRINT can be used to display values, strings, and the value of a variable
'(the last example will display "4" on the screen)
IF x = 4 THEN PRINT "x is equal to 4" 'Basic uses IF...THEN to test a value.
' What ever is after IF and before THEN is tested, if true whatever
' is after THEN is executed.
INPUT "Enter a number:", num1 ' Prompts for a number and stores it as num1.
You can do a lot with just those very basic principles. Basic is called "basic" because it's very basic. You're pretty much just speaking English to the computer. If you want to draw a line you use the LINE
command. A circle is the CIRCLE
command. Change colors? Use COLOR
. You can define variables with DIM
, but in QBASIC variables are not needed to be defined. They are just defined by QBASIC automatically when they are used. However, in Visual Basic, though they will also be defined automatically, it is much more common to define variables manually. Here's a very simple program using a few of the things I have mentioned.
CLS ' Clears the screen.
INPUT "What is your name"; Name$ 'Using the $ symbol will automatically define that variable as a STRING
PRINT "Hello "; Name$
INPUT "What would you like me to count to"; countnum
IF countnum < 0 THEN
PRINT "I cannot count negative numbers."
FOR x = 1 to countnum
PRINT "I am done counting."
INPUT "Would you like me to count again (y/n)"; yn$
IF LCASE$(yn$) = "y" THEN GOTO question
PRINT "Good bye."