Weekly Qbasic and Qb64 Lesson Topics
March 28, 2024, 03:56:12 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

The First lesson, by Garry

Pages: [1]
  Print  
Author Topic: The First lesson, by Garry  (Read 1717 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: April 12, 2012, 12:49:12 am »

Ok, the previous demo, has been modified and corrected, thanks due to Small No More, at qb64.net,..
 This is the corrected version:
Code:
DEFLNG A-Z
SCREEN 0
INPUT "What is your name "; name$
PRINT "Hello "; name$
PRINT " My name is Garry, I made this up,with the help of a tutorial,by Vic"
PRINT "Thank you, wait a couple of seconds to go on"
_DELAY 4
CLS
1 PRINT "These are some choices,of how many times to print something"
PRINT "NOTE 0 will exit the program"
PRINT " 0 exits,2,3,5 and 10,print that many times"
PRINT " 6 beeps six times,"
PRINT " 9 goes to another program "
INPUT "0,2,3,4,5,6,10,9"; number
IF number = 9 THEN
    CLS
    FOR i = 1 TO 0
        PRINT "you selected 9,now you will see screen 12"
        _DELAY 3
    NEXT
    GOTO 12
    END
END IF

IF number = 0 THEN
    END
END IF

IF number = 2 THEN
    CLS
    FOR i = 1 TO 2
        PRINT "You selected 2 "
    NEXT
    GOTO 1
END IF
IF number = 3 THEN
    CLS
    FOR i = 1 TO 3
        PRINT "You selected 3"
    NEXT
    GOTO 1
    END
END IF
IF number = 4 THEN
    CLS
    FOR i = 1 TO 4
        PRINT " you selected 4 "
    NEXT
    GOTO 1
    END
END IF
IF number = 5 THEN
    CLS
    FOR i = 1 TO 5
        PRINT "you selected 5 "
    NEXT
    GOTO 1
    END
END IF
IF number = 6 THEN
    CLS
    FOR i = 0 TO 1
        PRINT " 6 is going to be different"
    NEXT
    GOTO 2
    'END
END IF
IF number = 10 THEN
    CLS
    FOR i = 1 TO 10
        PRINT "you selected 10"
    NEXT
    GOTO 1
    END
END IF
2 PRINT "this is 6"
PLAY "aaaaaa"
PRINT " 3 x 2 ="
PRINT 3 * 2
_DELAY 2
GOTO 1
END

12
DEFINT A-Z

SCREEN 12
PRINT "Hello "; name$
PRINT "THIS WILL BE SCREEN 12"
PRINT "The following code dose not use GOTO,"
PRINT "Hit any key to continue"
SLEEP
CLS

Done = 0
start:
CLS
DO
    '/// This is PART 2 and it has a bug
    LOCATE 2, 10
    PRINT "WELCOME to Garrys invention"
    COLOR 2: PRINT "You Can do these things "
    '///Note it is in this part, that if any key other a number is "hit", it displays, the letter and  a number, for example v  111, the space key will cause a error, so I need to find out how to fix this.NOW it is fixed,

    PRINT "1)Multiply"
    PRINT "2)ADD"
    PRINT "3)Quit"
    Valid% = 0
    WHILE Valid% = 0
        Choice$ = INPUT$(1)

        Choice% = ASC(LTRIM$(Choice$))
        'PRINT Choice$, Choice% <===this line you was telling it to print the numbers and characters
        SELECT CASE Choice%
            CASE 49 TO 51
                Valid% = 1
            CASE ELSE
                Valid% = 0
        END SELECT
    WEND
    CLS
    SELECT CASE Choice%
        CASE 49 'multiply
            RANDOMIZE TIMER
            Num1% = INT(RND * 9) + 1
            Num2% = INT(RND * 9) + 1
            LOCATE 10, 2
            PRINT "The product of"; Num1%; " x "; Num2%; "= "
            INPUT Answer$
            Answer% = VAL(LTRIM$(Answer$))
            IF Answer% = Num1% * Num2% THEN
                PRINT "Correct "; Num1%; " x "; Num2%; " = "; Answer%
                SOUND 1000, 1
            ELSE
                PRINT "Wrong ";
                SOUND 600, 3
                Answer% = Num1% * Num2%
                PRINT Num1%; " x "; Num2%; " = "; Answer%
                _DELAY 3
            END IF
            PRINT Answer$
        CASE 50 'addition
            RANDOMIZE TIMER
            Num1% = INT(RND * 9) + 1
            Num2% = INT(RND * 9) + 1
            LOCATE 10, 2
            PRINT "The sum of"; Num1%; " + "; Num2%; "= "
            INPUT Answer$
            Answer% = VAL(LTRIM$(Answer$))
            IF Answer% = Num1% + Num2% THEN
                PRINT "Correct "; Num1%; " + "; Num2%; " = "; Answer%
                SOUND 1000, 1
            ELSE
                PRINT "Wrong ";
                SOUND 600, 3
                Answer% = Num1% + Num2%
                PRINT Num1%; " + "; Num2%; " = "; Answer%
                _DELAY 3
            END IF
        CASE 51 'quit
            Done = 1
    END SELECT
    _DELAY 1
    CLS
    PRINT "Press anykey to exit"
    _DELAY 2
    CLS
LOOP WHILE Done = 0
SLEEP
SYSTEM
' You can try this code, separate, just add start: to the top, right above dontdoit:
dontdoit:
CLS
LOCATE 12, 20: PRINT "Sorry input must be a number"
LOCATE 14, 20: PRINT "Returning to menu in 10 seconds"
SLEEP 10
GOTO start
Quote
  'PRINT Choice$, Choice% <===this line you was telling it to print the numbers and characters This is what needs to be removed,..using the ' in front of the code line, "remarks" it out, The ' Is used to indicate a line is a remark and not code to be executed.
So now, you should be starting to understand a little, about "codeing" with qb64,.. using a few commands, remarks,..  and also, when you get to the point where you do not understand, why it dose not work right, just ask,...someone will find a answer,.. also looking  at the wiki, http://qb64.net/wiki/index.php?title=Main_Page is a good place to start, when you need more info.
 
 
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy