Computer Science Canada [Problem] Is there any way to "Reload" a form when a button is pressed? |
Author: | amidomaru [ Tue Apr 28, 2009 8:43 pm ] |
Post subject: | [Problem] Is there any way to "Reload" a form when a button is pressed? |
I am running a simple card game program, and random cards are generated each run-through. However, the teacher wants us to have a button that re-loads the entire program from scratch once pressed, essentially starting from form_load. Is there any way that I can do this, or do I just have to load a second form, identical to the first, and delete the first form? I have tried using Unload and Load, but since I want the SAME form to be re-loaded, .visible and "hide" does not really help in this case. Any suggestions would be appreciated! |
Author: | Yurchinlax [ Sat Jun 06, 2009 1:10 pm ] |
Post subject: | RE:[Problem] Is there any way to "Reload" a form when a button is pressed? |
Remembering that form_load is a procedure, you could just call form_load eg. dim x as integer private sub Form_Load () x=5 print x end sub Private sub Button1_Click () call Form_Load() end sub Or, if you want to keep a variable, create a procedure in which form load calls, then when the button is pressed, call that procedure eg. dim x as integer private sub Form_Load () x=5 call Printer end sub private sub Printer print x end sub Private sub Button1_Click () call Printer end sub Hope this helped. |