473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Problems writing to the StatusBar form a Class

HI,
I am attempting to write to the StatusBar on MyForm from within a class that
I wrote. In the following code, VB does not like 'MyForm.StatusBar1.' VB
states, ' Reference to a non-shared member requires an object reference.'
Can you explain what VB is telling me and how can I resolve this problem.
I'm relatively new to OOP and .NET. Thanks.
Private Sub StatusUpdate()
MyForm.StatusBar1.Text = "Item " + CStr(Indx + 1) + " of " +
CStr(MyCount)
End Sub

--
GrandpaB
Nov 21 '05 #1
2 1078
the long and short of it is that your Child form has no access to the
Statusbar on "Myform"

Here is one way to to it:

Child class (your class that needs to set the Statusbar). There are
two subroutines here: "New" receives the name of the object that has
the statusbar, and the LocalfrmMain object is set to reference it. In
the "setstatus" subroutine, you can set the statusbar to whatever you
like
Public Class Class1
Dim LocalfrmMain As Form1
Public Sub New(ByRef MyOwner As Object)
LocalfrmMain = MyOwner
End Sub
Public Sub setstatus()
LocalfrmMain.StatusBar1.Text = Now.ToString
End Sub
End Class
In MyForm (which has the status bar), when you declare your class, pass
the word "Me" to it

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim c1 As New Class1(Me)
c1.setstatus()
c1 = Nothing
End Sub

Nov 21 '05 #2
Jerry,

Thanks, that did the trick. If you don't mind, I'd appreciate a reference
or explaination of what you did to Improve my knowledge and understanding.
--
GrandpaB

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John J. Hughes II | last post by:
I have an MDI application and would like to display messages to the status bar of he parent window. I am really not happy about putting a status bar on every MDI window and would prefer it to only...
3
by: TonyM | last post by:
Hi all, I have an application with a few different Windows forms. I am trying to update a statusbar panel's text that is in the main form, from another form. When I set the statusbar and the...
9
by: Christian Blackburn | last post by:
Hi Gang, I've had this happen with a couple of controls now, but my patience has worn thin. Can somebody tell me why I can read/write to most objects on my form from my module, but not when...
4
by: rat | last post by:
i am having 3 panels(0,1 & 2) in a Statusbar. Using MDI form, i can access and set the text for the panels(0 and 2).. But how can i access the panel(1) from MDI Child form. like...
14
by: Kishan Hathiwala | last post by:
Hi i have kept a statusbar in the form with panels = true. and total there 3 panels. whenever i click on the 3rd panel a menu appears showing online and offline and either is enable at a time....
1
by: herve | last post by:
Hi, everybody I'm working with wxPython 2.8.1.1. Does anybody know how to change the foreground colors in a wx.StatusBar
8
by: giddy | last post by:
hi , Does a singleton statusbas controller sound correct. I mean , is that how its done? I have a big app and i need to control the statusbar from within a number of custom controls , dynamic...
3
by: S. Viswanathan | last post by:
Hi everybody! In VB.NET 2005, MenuStrip and Statusstrip controls added. When the mouse over on the Menuitem its corresponding Tooptip text should be displayed in the statusstrip. How to...
3
by: John Dann | last post by:
Trying to learn Python here, but getting tangled up with variable scope across functions, modules etc and associated problems. Can anyone advise please? Learning project is a GUI-based...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.