A small question. - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: A small question. (/thread-6641.html) Pages:
1
2
|
A small question. - p3t3r - 03-28-2005 Hi I have a little code problem in Qbasic and wonder if anyone know the solution. I made a trivia program for school. It's nearly complete except for this one problem. Here is the part of my code that has a problem. (in Bold) Quote:'*************************************************************************** I put the sleep command there because by doing so I can allow user to press any key to continue to the next screen. It works well other than the fact that the first INPUT command after the sleep command won't work. It display the question there but doesn't allow you to input anything. The second input works but I don't want to use it because its sort of faulty coding and going to cost me marks. I tried a number of different ways but couldn't find out why this is happening. Anyone know how to solve it? Thanks alo A small question. - Mitthrawnuruodo - 03-28-2005 Ok, this is easy, and should be in the noob one...but anyways.... Your trying to input a string value into a number variable. To fix it: Use: username$ Instead of: username Now your inputing a string value into a string variable. A small question. - adosorken - 03-28-2005 Yeah Mitth, that's one of the problems, but there's another one lurking in there as well...and it involves that dreaded SLEEP command. p3t3r, replace Code: SLEEP Code: DO: LOOP WHILE INKEY$ = "" Also, if you don't want to change username to username$, you can always do this before you use the variable: Code: DIM username AS STRING A small question. - Mitthrawnuruodo - 03-28-2005 Ya? Well, I NEVER press enter to pass a sleep....well I guess that's why I didn't see that...heh :roll: I like the $ at the end of the variable better, it keeps you from getting conused on what kind of variable it is, so I know I'm not doing a len() to a number, or a cos() to a string....lol :lol: A small question. - TheBigBasicQ - 03-28-2005 You can also try this(dunno if it will work correctly): Code: CLS A small question. - p3t3r - 03-28-2005 Hey, thanks for the replies. Quote:Also, if you don't want to change username to username$, you can always do this before you use the variable: I did DIM the username as string in my program but I didn't post that part of the code. Could it still be the root of the problem? Thanks for the tip adosorken. I think it will fix the input problem until I can find the root of the sleep problem. Thanks alot. A small question. - Anonymous - 03-29-2005 dude, fuck sleep. never ever use it unless youre programming in FB, kay? use like while inkey$ = "": wend or do while inkey$ = "": loop never use sleep. ever. i mean it. A small question. - Mitthrawnuruodo - 03-29-2005 *sigh* no one ever thanx me.... :roll: Well if you aready dimed them as strings and there spelled the same then that is not the problem...CHANGE THE SLEEP! ok, the sleeps the prob....change it to DO:LOOP WHILE INKEY$ = "". That should be it! A small question. - na_th_an - 03-29-2005 Code: SLEEP: k$ = INKEY$ Works flawlessly in QB. Why not use it? A small question. - TheBigBasicQ - 03-30-2005 thats two statements. AFAIK this should work the same: Code: dummy$ = input$(1) |