This is my first program in Qbasic, it works fine! However in the input sections i cannot use any thing other that numbers and, yes ive tried with signs like : %, $ and stuff like that! Could someone help me understand how i can make
"IF number = 1 GOTO start2 ELSE GOTO start"
into
"IF number = haha GOTO start2 ELSE GOTO start"
CLS
Color 2
start:
INPUT " Enter Username ", number,
IF number = 1 GOTO start2 ELSE GOTO start
start2:
INPUT " Enter Password ", number,
IF number = 321 GOTO start3 ELSE GOTO start
start3:
CLS
Color 2
PRINT " Velkommen til 2ela "
INPUT " Ka vil du gjera? ", number,
IF number = 1 GOTO start4 ELSE GOTO start3
start4:
CLS
Color 2
PRINT " Klassen 2012 "
PRINT " Kenneth Blokhus 1 "
PRINT " ooystein Nyg?rd 2 "
PRINT " Erling Hovland 3 "
PRINT " Henrik Hovland 4 "
PRINT " Erlend Haugland 5 "
PRINT " Aleksander Kol?y 6 "
PRINT " Andreas Huse 7 "
PRINT " Kristoffer Andreassen 8 "
PRINT " Torstein Landa 9 "
INPUT " Kin vil du veta om? ", number,
IF number = 1 THEN GOTO kenneth
IF number = 2 THEN GOTO ooystein
IF number = 3 THEN GOTO erling
IF number = 4 THEN GOTO henrik
IF number = 5 THEN GOTO erlend
IF number = 6 THEN GOTO aleksander
IF number = 7 THEN GOTO andreas
IF number = 8 THEN GOTO kristoffer
IF number = 9 THEN GOTO torstein ELSE GOTO start3
kenneth:
CLS
Color 2
PRINT " Hei Kenneth "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
ooystein:
CLS
Color 2
PRINT " Hei Ooystein "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
erling:
CLS
Color 2
PRINT " Hei Erling "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
henrik:
CLS
Color 2
PRINT " Hei Henrik "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
erlend:
CLS
Color 2
PRINT " Hei Erlend "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
aleksander:
CLS
Color 2
PRINT " Hei Aleksander "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
andreas:
CLS
Color 2
PRINT " Hei Andreas "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
kristoffer:
CLS
Color 2
PRINT " Hei Kristoffer "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
torstein:
CLS
Color 2
PRINT " Hei Torstein "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
UserName, Password, Number!
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
String variables use $ to indicate a STRING value like: word$
INPUT "Enter your name: ", name$ 'no end comma
The problem with string entries is that $$$ must be exact! "ABC" does not equal "abc". You can change a STRING to all uppercase with:
name$ = UCASE$(name$)
name$ = LCASE$(name$)
IF name$ = "ted" GOTO mylabel 'line label or number
Line labels must end with a colon like
mylabel:
Labels must be designated before you attempt to run or error. I do not recommend GOTO as a great way to program. Use loops if you can.
http://qb64.net/wiki/index.php?title=Ke ... phabetical
INPUT "Enter your name: ", name$ 'no end comma
The problem with string entries is that $$$ must be exact! "ABC" does not equal "abc". You can change a STRING to all uppercase with:
name$ = UCASE$(name$)
name$ = LCASE$(name$)
IF name$ = "ted" GOTO mylabel 'line label or number
Line labels must end with a colon like
mylabel:
Labels must be designated before you attempt to run or error. I do not recommend GOTO as a great way to program. Use loops if you can.
http://qb64.net/wiki/index.php?title=Ke ... phabetical
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
-
- Newbie
- Posts: 2
- Joined: Mon Dec 19, 2011 4:54 pm
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Well GOTO can become too easy to use as a way to do everything. It can trap new users by steering the program flow from one place to another without any sense of where you will end up.
A program is a series of code statements that are executed in order down the page. When you get to the bottom there is a tendency to use GOTO to go back to the top. That is where loops come in. You can use loops to repeat code and have an option that exits the loop when you are done.
GOTO just sends you from one place to another without any plan so your code may even confuse you after a while. It is hard to keep track or follow the program flow and it actually may become harder to program. This can actually discourage new programmers!
A program is a series of code statements that are executed in order down the page. When you get to the bottom there is a tendency to use GOTO to go back to the top. That is where loops come in. You can use loops to repeat code and have an option that exits the loop when you are done.
GOTO just sends you from one place to another without any plan so your code may even confuse you after a while. It is hard to keep track or follow the program flow and it actually may become harder to program. This can actually discourage new programmers!
Code: Select all
CLS
Color 2
start:
INPUT " Enter Username ", number
IF number = 1 GOTO start2 ELSE GOTO start
start2:
INPUT " Enter Password ", number,
IF number = 321 GOTO start3 ELSE GOTO start
start3:
CLS
Color 2
PRINT " Velkommen til 2ela "
INPUT " Ka vil du gjera? ", number,
IF number = 1 GOTO start4 ELSE GOTO start3
start4: DO '<<<<<<<<<<<<<<<<<<<start loop
CLS
Color 2
PRINT " Klassen 2012 "
PRINT " Kenneth Blokhus 1 "
PRINT " ooystein Nyg?rd 2 "
PRINT " Erling Hovland 3 "
PRINT " Henrik Hovland 4 "
PRINT " Erlend Haugland 5 "
PRINT " Aleksander Kol?y 6 "
PRINT " Andreas Huse 7 "
PRINT " Kristoffer Andreassen 8 "
PRINT " Torstein Landa 9 "
INPUT " Kin vil du veta om? ", number,
IF number = 1 THEN GOTO kenneth
IF number = 2 THEN GOTO ooystein
IF number = 3 THEN GOTO erling
IF number = 4 THEN GOTO henrik
IF number = 5 THEN GOTO erlend
IF number = 6 THEN GOTO aleksander
IF number = 7 THEN GOTO andreas
IF number = 8 THEN GOTO kristoffer
IF number = 9 THEN GOTO torstein ELSE GOTO start3
kenneth:
CLS
Color 2
PRINT " Hei Kenneth "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
ooystein:
CLS
Color 2
PRINT " Hei Ooystein "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
erling:
CLS
Color 2
PRINT " Hei Erling "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
henrik:
CLS
Color 2
PRINT " Hei Henrik "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
erlend:
CLS
Color 2
PRINT " Hei Erlend "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
aleksander:
CLS
Color 2
PRINT " Hei Aleksander "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
andreas:
CLS
Color 2
PRINT " Hei Andreas "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
kristoffer:
CLS
Color 2
PRINT " Hei Kristoffer "
INPUT " Tilbake? ", number,
IF number = 1 THEN GOTO start4 ELSE End
torstein:
CLS
Color 2
PRINT " Hei Torstein "
INPUT " Tilbake?(Y/N) ", quit$
quit$ = UCASE$(quit$)
LOOP UNTIL quit$ <> "Y" '<<<<<<<<<<<<<end loop if not "Y"
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0