it's possivel reload the actual form?
thanks
Printable View
it's possivel reload the actual form?
thanks
It is possible to reload any form provided it is not already loaded.
What does "the actual form" mean? :confused:
This will unload the form...!
And this will show/load the Form:Code:Unload Form1
... :wave:Code:Form1.show
Or you can include those things that will be executed on starting the game inside a sub or function. Example:
And another for unloading:Code:Public Function StartGame()
'// Load sprites
'// Load Graphics
'// Load configuration, etc.
End Function
So, when the user wants to restart the game, call EndGame and then call the StartGame....Code:Public Function EndGame()
'// unLoad sprites
'// unLoad Graphics
'// unLoad configuration, etc.
End Function
It's just a thought... :wave:
I'm assuming you have all your code within secregated methods and not in your form events.
Thus you should be able to simply re-call the methods which initialize your game-screen, your variables and objects.
However, If you really must re-load the form you need to free the current form from memory first before you reload it:
VB Code:
Unload Form1 Set Form1 = Nothing Load Form1 Form1.Show
If you do not set the actual form to nothing the Form_Initialize() event will not be triggered a consecutive time.
If you are using a Form variable you still must set the actual form to nothing as well or you also get the problem of the Form_Initialize() event not firing again when reloading the form.
The reason for this is that VB's Unload removes the form or control from memory but not the actual code page. The form's code page still resides in memory untill you set the actual Form1 object to nothing.
in these case i can't use unload, because i can't unload the form that i'm using;).
but is slow, is like pause the program(in these case the game), then load the form.
what you can tell me?
akhileshbc, i like you sugestion, i build 1 similar situation. but instead work with every controls(it's a diferent way that i build a game;)), i wanted do these not so "complex";)
thanks