Valhalla Legends Forums Archive | .NET Platform | Reference to a non-shared member requires an object reference.

AuthorMessageTime
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?
September 28, 2004, 12:33 AM
K
you need to reference your richtext box from an object instance, not from the name of the class.

[code]
// right
Form1 fMain = new Form1()
fMain.someRichTextBox.DoSomething()

//wrong
Form1.someRichTextBox.DoSomething()
[/code]
September 28, 2004, 1:22 AM
Myndfyr
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.
September 28, 2004, 6:42 AM

Search