"Chris Ashley" <ch**********@SPAMblueyonder.co.uk> wrote in message
news:416ce78a.0@entanet...
I have a class called App set as the startup object with the following
code:
Friend Class App
Shared Sub Main()
Dim FrmMain As New MainForm
Application.Run(FrmMain)
End Sub
End Class
In another form I use the following code:
Private Sub AddCustomer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
FrmMain.Text = "Add Customer"
End Sub
I get the error that FrmMain is not declared. Didn't I get a reference to
it called FrmMain in my Sub Main? How else can I get a reference to the
startup form?
Regards,
Chris
I sorted this by using a shared property in my startup class. Here's the
code I'm using now:
Public Class App
Private Shared m_FrmMain As MainForm
Public Shared Property FrmMain() As MainForm
Get
Return m_FrmMain
End Get
Set(ByVal Value As MainForm)
m_FrmMain = Value
End Set
End Property
<STAThread()> _
Shared Sub Main()
Dim FrmStart As New MainForm
FrmMain = FrmStart
FrmMain.ShowDialog()
End Sub
End Class
Now I can access my main form through App.FrmMain - was this the right way
to do this?
Regards,
Chris