: This message was edited by the satsoc at 2002-4-5 14:35:53
: This message was edited by the satsoc at 2002-4-5 14:18:16
: : : i have to make a program with an option that after it finishes we can repeat the procedure all over again.Something like :
: : : repeat? (Yes,No).if yes then we clear the screen and start the procedure again.
: : :
: : : Any help?
: : :
: : Start your program with a function call (maybe void main() or initParameters). Then at the end of the procedure, display a messagebox:
: : retVal = msgbox("Do you want to repeat?",vbYesNo,"Repeat?")
: : if retVal = vbYes
: : ClearParameters ' Clear variables and reset properties
: : InitParameters ' Start over
: : else
: : End ' End the program
: : end if
: : This way, you can reset whatever you need to in ClearParameters and can call one procedure to start over again. You can probably compress the statements into fewer lines, but this is for clarity.
: newbie question but shouldn't i call the function into a variable?because when i declare the function main(),for example,into a sub
: then i have error messages.where do you think should i use this code?
: ok man.i've got it.
: thanks for your help
The void Main() is a Sub that VB uses if there isn't a form. It can be set in the Project Properties box. But you can call the code from anywhere, but it should be done after you perform your procedure.
Private Sub Main()
InitParameters ' InitParameters is a Sub
' or retVal = InitParameters if InitParameters is a function
Private Function DoStuff() as boolean
' Do procedure stuff here
if Msgbox("Do you wanna repeat?",vbYesNo) = vbYes then
' Finish code here, clear variables, can be in a separate function