Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Guest mutant
Posted

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

Posted

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.

Gamer extraordinaire. Programmer wannabe.
Posted

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.

Guest mutant
Posted

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.

Posted

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

Guest mutant
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...