: 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: [code] [green]' 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.[/green] x = 1 [green]'Sets x equal to 1[/green] x = x + 1 [green]'Sets x equal to x + 1[/green] PRINT 1 PRINT "Hello" x = 4 PRINT x [green]'PRINT can be used to display values, strings, and the value of a variable '(the last example will display "4" on the screen)[/green] IF x = 4 THEN PRINT "x is equal to 4" [green]'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.[/green] INPUT "Enter a number:", num1 [green]' Prompts for a number and stores it as [italic]num1[/italic].[/green] [/code]
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 [b]LINE[/b] command. A circle is the [b]CIRCLE[/b] command. Change colors? Use [b]COLOR[/b]. You can define variables with [b]DIM[/b], 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.
[code] CLS [green]' Clears the screen.[/green] INPUT "What is your name"; Name$ [green]'Using the $ symbol will automatically define that variable as a STRING[/green] PRINT "Hello "; Name$ question: INPUT "What would you like me to count to"; countnum IF countnum < 0 THEN PRINT "I cannot count negative numbers." GOTO question END IF FOR x = 1 to countnum PRINT x, NEXT PRINT 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." [/code]
Comments
: by the way, i can program in c++ a bit...
:
Hey there
I'm a die heard QBASIC programmer and have some cracking code. get in touch with me at y2keable@hotmail.com and a'll send ya some of ma stuff.
: 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:
[code]
[green]' 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.[/green]
x = 1 [green]'Sets x equal to 1[/green]
x = x + 1 [green]'Sets x equal to x + 1[/green]
PRINT 1
PRINT "Hello"
x = 4
PRINT x [green]'PRINT can be used to display values, strings, and the value of a variable
'(the last example will display "4" on the screen)[/green]
IF x = 4 THEN PRINT "x is equal to 4" [green]'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.[/green]
INPUT "Enter a number:", num1 [green]' Prompts for a number and stores it as [italic]num1[/italic].[/green]
[/code]
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 [b]LINE[/b] command. A circle is the [b]CIRCLE[/b] command. Change colors? Use [b]COLOR[/b]. You can define variables with [b]DIM[/b], 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.
[code]
CLS [green]' Clears the screen.[/green]
INPUT "What is your name"; Name$ [green]'Using the $ symbol will automatically define that variable as a STRING[/green]
PRINT "Hello "; Name$
question:
INPUT "What would you like me to count to"; countnum
IF countnum < 0 THEN
PRINT "I cannot count negative numbers."
GOTO question
END IF
FOR x = 1 to countnum
PRINT x,
NEXT
PRINT
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."
[/code]