Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-activate Current Form?

Status
Not open for further replies.

ilovevbsomuchimmad

Programmer
Feb 5, 2007
18
0
0
GB
Hi, I was wondering is it possible to re-activate the current form? I have some coding which is in the form activate, and that coding needs to be run a few times but the only way I can get it to work is clicking on to another form and returning to the form. I have tried me.activate, or frmmain.activate but none seem to work.
 
Put the Form_Activate code in its own sub, and call that sub from Form_Activate and whenever else it is needed.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Sorry but is it possible if you could give me a quick example? Its just im new to vb.
 
ilovevbsomuchimmad,

Put the Form_Activate code in its own sub, and call that sub from Form_Activate and whenever else it is needed.

Create a sub like below and put ONLY there the code you have in the Activated event handler.

Code:
private sub GiveItAName()
   ' the code
end sub

So the Activated eh becomes:

Code:
    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        GiveItAName()
    End Sub

Whenever and wherever your write the line 'GiveItAName()', the code in that sub will be executed.


------------
[Not recommented] If for some reason you want to keep the code only in the activated sub, call it like: Form1_Activated(Nothing, Nothing)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top