Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Problem] Is there any way to "Reload" a form when a button is pressed?
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
amidomaru




PostPosted: 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!
Sponsor
Sponsor
Sponsor
sponsor
Yurchinlax




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: