Basic - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Basic

viki007viki007 Posts: 46Member
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...

Comments

  • y2keabley2keable Posts: 23Member
    : 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.


  • the walrusthe walrus Posts: 249Member
    : 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]
Sign In or Register to comment.