Inheriting a value in a varible

G

Guest

Hello. I am using vb.net.

There are two forms in my project. One is 'base' and the other one is
'savecurrent'.

There is a value stored in a textbox called 'qc_a' in 'base'. I want to
inherit it in 'savecurrent' when a button (located in 'savecurrent') is
clicked. So a declared an Object varible, whose name is 'equation' in
'savecurrent' and typed in the following code:

equation = base.qc_a.Text()

Then VB underlined 'base.qc_a' and said 'Reference to a non-shared member
requires an object reference'.

Could anybody tell me how to fix this? Thanks.
 
C

Cor Ligthert

Xero,

What do you main with inheriting in this statement and what with variable?

Please do not use terms which does not belong to the question in the subject
text.

Probably yo can make your program working by setting the string qc_Text to
shared in the class base.

I hope this helps?

Cor
 
K

Ken Tucker [MVP]

Hi,

You need a reference to the form base to access its members.
Here is a possible solution. Add this to the form base.

Private Shared frm As base

Public Shared ReadOnly Property DefInstance() As base

Get

If frm Is Nothing Then frm = New base

Return frm

End Get

End Property



Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

frm = Me

End Sub



Use it this way.

equation = base.definstance.qc_a.Text()


Ken
--------------------

Hello. I am using vb.net.

There are two forms in my project. One is 'base' and the other one is
'savecurrent'.

There is a value stored in a textbox called 'qc_a' in 'base'. I want to
inherit it in 'savecurrent' when a button (located in 'savecurrent') is
clicked. So a declared an Object varible, whose name is 'equation' in
'savecurrent' and typed in the following code:

equation = base.qc_a.Text()

Then VB underlined 'base.qc_a' and said 'Reference to a non-shared member
requires an object reference'.

Could anybody tell me how to fix this? Thanks.
 
H

Herfried K. Wagner [MVP]

Xero said:
There are two forms in my project. One is 'base' and the
other one is 'savecurrent'.

There is a value stored in a textbox called 'qc_a' in 'base'.
I want to inherit it in 'savecurrent' when a button (located
in 'savecurrent') is clicked. So a declared an Object varible,
whose name is 'equation' in 'savecurrent' and typed in the
following code:

equation = base.qc_a.Text()

Then VB underlined 'base.qc_a' and said 'Reference to a non-
shared member requires an object reference'.

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top