PLEASE ANSWER ASAP!!!!!!!

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

PLEASE ANSWER ASAP!!!!!!!

Post by Sinuvoid »

how do you go back to the main moduel thing or the starting of the program after youre in a SUB??
User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Post by Stoves »

The F2 key switches between subs and the main program.
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Sorry but not that stoves :?
I mean when you have choice's and then you go to a sub but then i need to get back to the choice's.
User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Post by Stoves »

If you're talking about this screen:

Image

Then the only key I'm aware of to get to it is the F2 key. You should also be able to use the menu options to get to it.

Image
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

I understand the question, but it's impossible to explain the answer without seeing the code in question.
User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Post by Stoves »

Yeah, if it's an issue with code, maybe you can post the code that's giving you problems.


I don't know if this is what you're looking for, but you might be able to use a DO/LOOP to return to your choices if it's a menu in your program.

Code: Select all

DO

'Code that display's menu and gets user input.

SELECT CASE userInput
    CASE 'choice that calls a particular SUB
        doSomething
    CASE 'choice that sets a value or calls another SUB
        something = 1
        doSomethingElse
    CASE ELSE 'default choice
        something = 0
END SELECT

END SELECT

LOOP
The code/pseudocode above will keep looping through the choices and after running a subroutine if a particular choice is made, will return to the choices.
Anonymous

Post by Anonymous »

Hi,

If i understand correctly you want to know how you're code goes back to the main module when you are running the code.

Say I have a sub named DisplayText, I would call it in my main module like so

Code: Select all

call DisplayText()
Now when DisplayText is called it runs the code in DisplayText until it gets to the end of the sub (END SUB), or unless you use EXIT SUB. So say I have this code in DisplayText


Code: Select all

sub DisplayText() 
 Print "Hello, please type your name"
 input usertext$
 if usertext$ = "q" then
      exit sub
 else
      print "You enter " + usertext$
 end if
end sub
Now once the code in the sub has finished running it will go back to the main module and move to the next line of code.

Code: Select all

print "Before sub"
call DisplayText
print "After sub"
Hope this helps
Post Reply