sjn78 Posted May 10, 2003 Posted May 10, 2003 I have a child form that calls this SB.Text("Sending Email") The class for the above is Class SB Public Shared Sub Text(ByVal txt As String) Dim frm As New FrmMain() frm.SBMain.Text = txt End Sub End Class SBMain is the statusbar. Why won't the statusbar update on the main form? Any help would be great. Thanks Quote
Guest mutant Posted May 10, 2003 Posted May 10, 2003 You are creating a new instance of the main form everytime. You have to pass in the instance of the form to that sub. Something like: Public Shared Sub Text(ByVal txt As String, ByVal yourform as FrmMain) yourform.SBMain.Text = txt End Sub Quote
wyrd Posted May 10, 2003 Posted May 10, 2003 What mutant said, plus.. It won't display the text if you have panels on your status bar, so if that's the case you'll need to update the panel directly. Also make sure the status bar is public so it can be accessed outside of the form. Controls are usually private by default. Quote Gamer extraordinaire. Programmer wannabe.
sjn78 Posted May 10, 2003 Author Posted May 10, 2003 The statubar doesn't have panels....i'm not that clever yet. I changed the function to what you said and still no luck. when calling the function, what form should I use ? sb.text("Message", ??) Thanks for helping out. I have only just moved to .NET from VB6 and have much to learn. Quote
Guest mutant Posted May 10, 2003 Posted May 10, 2003 If you are calling that sub from your form class then just type Me in there. If not from your form class than show us the code you call it from and where it is. Quote
sjn78 Posted May 10, 2003 Author Posted May 10, 2003 Ok, this is what I have FrmMain with the statusbar on it FrmEmail where I am trying to call the sb.text() ClsMain where the sb.text is defined Quote
Guest mutant Posted May 10, 2003 Posted May 10, 2003 Ok, so you update status bar only. So when you create new instance of your frmEmail, when you show it from frmMain, pass in the the instance of your status bar to frmEmail. You have to overload the constructor to do that. Put this in your FrmEmail: Dim barinstance as StatusBar 'variable to hold the instance Public Sub New(ByVal bar as StatusBar) MyBase.New InitializeComponent() barinstance = bar 'assign the instance to variable 'now you can access that statusbar in this class End Sub Now when you call you sub that changes text on panel call it like this: sb.Text("Message", barinstance) And Make you Text sub accept those arguments: ByVal txt As String, ByVal yourbar As StatusBar And now you can manipulate the StatusBar that is in the frmMain. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.