473,503 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheriting a value in a varible

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.

--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #1
4 1347
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

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )>
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.

--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #2
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
--------------------

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:C2**********************************@microsof t.com...
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.

--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #3
"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> schrieb:
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>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4
I see.
Thanks very much.

Xero
"Ken Tucker [MVP]" wrote:
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
--------------------

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:C2**********************************@microsof t.com...
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.

--
Xero

http://www.chezjeff.net
My personal web portal

Nov 21 '05 #5

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

Similar topics

1
1266
by: Yasutaka Ito | last post by:
Hi, I have a base form (FormBase), which defines things like the value of the WindowState. Other forms inherit from this base form to reflect the layout given in the base form. Is there a way...
2
1799
by: Charles Law | last post by:
I want a set of controls that all have a border, like a group box. I thought I would create a base control containing just a group box from which my set of controls could inherit. Assuming that...
1
1132
by: Peter | last post by:
Does anybody know how to convert a string to a varible? For example, I have defined 2 structures Structure SS dim Name as string dim ID as short end structure Structure TT
3
4056
by: Roy Soltoff | last post by:
Two books, "Mastering Visual Basic.Net" and "Visual Basic.Net Developer's Handbook" describe inheriting from System.EventArgs using a class similar to: Public Class MyEventArgs Inherits...
10
3922
by: John Bailo | last post by:
I want to pass a SqlCommand object as a input parameter to a method. I want to pass the SqlCommand "by value" so that any updates to the original object are *not* reflected in the object within...
2
2294
by: Aido82 | last post by:
Hi, this is probably a stupid question. Im trying to declare a varible to have the value of that in a text box when i declare the varible is there a way to give it the value in a text box...
17
2411
by: Adrian Hawryluk | last post by:
Hi all, What is everyone's opinion of const inheriting? Should the object that a pointer is pointing at inherit the constness of the pointer? Such as in the case of a class having a pointer...
3
1417
by: Sachin | last post by:
Hi Folks, I have one query in regarding const varible interpretaion by C/C++ compiler. How Compiler actually differentiate between normal stack varible and const varible during program execution?...
5
1540
by: jc | last post by:
RE: Two Classes with the same Data Structure.. saving code? Inheriting a structure? I have two classes. One in Inherits System.Collections.CollectionBase, the other does not, but they both have...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7330
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
5578
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.