View Single Post
Old Sep 10th, 2005, 2:51 PM   #9
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
You could declare your main form's instance as a public shared variable: if your project runs the main form, you'll need to create global a main() routine for startup, i.e.

Public Shared ifrmSomeForm As frmSomeForm

Public Sub Main()
        ifrmSomeForm = New frmSomeForm ' We create the instance here as opposed to in the variable declaration as that could lead to multithreading problems
        ifrmSomeForm.Show()
        ' Insert application shutdown code here
End Sub

Then wherever you are, the main instance of the form frmSomeForm can be accessed via ifrmSomeForm without worrying about race conditions etc.
Rory is offline   Reply With Quote