repeating a procedure - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

repeating a procedure

satsocsatsoc Posts: 19Member
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?

Comments

  • hobbyhobby Posts: 84Member
    : 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:
    [code]
    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
    [/code]

    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.

  • satsocsatsoc Posts: 19Member
    [b][red]This message was edited by the satsoc at 2002-4-5 14:35:53[/red][/b][hr]
    [b][red]This message was edited by the satsoc at 2002-4-5 14:18:16[/red][/b][hr]
    : : 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:
    : [code]
    : 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
    : [/code]
    :
    : 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





  • hobbyhobby Posts: 84Member
    : [b][red]This message was edited by the satsoc at 2002-4-5 14:35:53[/red][/b][hr]
    : [b][red]This message was edited by the satsoc at 2002-4-5 14:18:16[/red][/b][hr]
    : : : 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:
    : : [code]
    : : 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
    : : [/code]
    : :
    : : 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.

    [code]
    Private Sub Main()
    InitParameters ' InitParameters is a Sub
    ' or retVal = InitParameters if InitParameters is a function
    End Sub

    Private Function DoStuff() as boolean
    ' Do procedure stuff here

    if Msgbox("Do you wanna repeat?",vbYesNo) = vbYes then
    InitParameters
    DoStuff
    End if

    ' Finish code here, clear variables, can be in a separate function
    End Function

Sign In or Register to comment.