Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 1677
Number of posts: 4766

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Basic Posted by viki007 on 12 Nov 2003 at 6:13 AM
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...
Report
Re: Basic Posted by y2keable on 12 Nov 2003 at 8:21 AM
: 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...
:
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.


Report
Re: Basic Posted by the walrus on 12 Nov 2003 at 12:27 PM
: 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
PRINT 1
PRINT "Hello"
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$
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."




 

Recent Jobs