(Reference to a non-shared member requires an object reference) Help

Ok I have 2 listbox, a panel, and a user control with a textbox on it.

When I click on listbox1 listbox2 is filled with data and the user control is loaded into a panel. This is where I need help: I'm supose to be able to click listbox2 once it's filled with data and have a textbox on the user control fill with some text.

Here's the part of code for listbox2 I am having troble with.

'BipedEditor.Textbox1 is the textbox loacated on the user control

'Reference to a non-shared member requires an object reference is the error I get for the text in pink

'It's because the textbox isn't on the form that this code is on

BipedEditor.TextBox1.Text = BR.ReadSingle

BR.Close()

EndIf

BipedEditor is the user control

Textbox1 is the textbox on the user control

How do I reference a non-shared member?

[1091 byte] By [jebtrillion] at [2008-1-10]
# 1
jebtrillion wrote:
BipedEditor is the user control

Textbox1 is the textbox on the user control

It's only a guess but I suspect that BipedEditor is the type of the user control and that the actual user control instance on your form is called BipedEditor1 or some other name.

FrankBoyne at 2007-10-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

The text in red is where I get the error

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

Forerunner.BipedEditor.JumpHeightBOX.Text = ("Test1")

-Things you should know

-The code above is on the main form and it's calling a texbox named JumpHeight thats on the form BipedEditor

-Forerunner is the project

Anyone know?

Thanks in advance

jebtrillion at 2007-10-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

You are referencing that textbook via it's non-instantiated name.

That form is a class and has been instantiated. You need to find out what name it's instantiated in and

address it as instance.JumpHeight.Text.

ReneeC at 2007-10-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

Another way i've found is to simply create a Module1.vb in which you declare:

Public Form1_Clone as New Form1 'Form1 is as normally designed Form but in .Net it is considered as a class

Public Form2_Clone as New Form2 'Form2 is as normally designed Form but in .Net it is considered as a class

.

.

and so on

When you whish to "Show" a form, call Module1.Form1_Clone.Show()

From where ever you whish to access control objects on Form1_Clone (which is now displayed), simply use Form1_Clone.TextBox1.Text

Hope this help.

SilverMC at 2007-10-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...