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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DirectCast in a class

Status
Not open for further replies.

JHPeter

Programmer
Apr 17, 2003
8
GB
I want to write to a status bar from a class, is DirectCast the way to go as I cannot get it to work.

DirectCast(Me.Owner,MainForm).stbMain.Panels(1).Text = "xyz"
works fine from a form but not in a namespace/class.

Can this be achieved?
 
If your statusbar is on your main form you need to pass the main form into your class

Code:
Class myStatusBar
 
  ' Assuming frmMain is your form with the statusbar
  Shared Sub WriteStatusBarMSG(ByVal Message as String, ByRef f as frmMain)

    f.Statusbar1.Text = Message 

  End Sub

End Class

' Your call from the main form

Sub Whatever()
    
  myStatusbar.WriteStatusBarMSG("Hello", Me)
    
End Sub

But if you intend to use it from another form, say an MDI child, you need to pass your main form to the child as a reference, then call it using your referenced main form.

Hope you understand what I'm trying to say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top