• Welcome to Valhalla Legends Archive.
 

Reference to a non-shared member requires an object reference.

Started by CrAz3D, September 27, 2004, 07:33 PM

Previous topic - Next topic

CrAz3D

The above is what VB.NET tells me is wrong when I try to access my RichTextBox that is on Form1.  I am trying to access it from a module.  Are there any special properties that the RTB needs?...or something in the module for that matter?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

K

you need to reference your richtext box from an object instance, not from the name of the class.


// right
Form1 fMain = new Form1()
fMain.someRichTextBox.DoSomething()

//wrong
Form1.someRichTextBox.DoSomething()

MyndFyre

Although, doing it the way K suggests will probably not be what you desire, because it won't change the RTB on your existing form.

Rather, make sure that the module has access to the form instance on which the object you want to modify exists.  For instance, if you have a Form1 instance called myForm1, then in the module, rather than saying Form1.blahblahblah, use myForm1.blahblahblah.

If you don't understand what an object instance is, read the "What's New in VB .NET" section of Help.  Then come back to talk to us.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.