473,467 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

referencing variable across forms

18 New Member
Hi again! hope there is no limit to posting newbies questions but this will probably be my last one for a while! I have managed to find some answers to other questions in my mind on here..yippy!

Ok i wanted to know how to refer to a variable from (maybe from a text box) on one form to another form. I have managed to refer to them currently by passing them along to each new created form everytime (one by one) but wanted to refer to a variable from form 1 to say form 5, how can i do this? I read something about creating a Module..would that be just like creating forms instead and then all the variables will be global?

Thank you for any knowledge u can impart!
Oct 1 '07 #1
5 1468
r035198x
13,262 MVP
Hi again! hope there is no limit to posting newbies questions but this will probably be my last one for a while! I have managed to find some answers to other questions in my mind on here..yippy!

Ok i wanted to know how to refer to a variable from (maybe from a text box) on one form to another form. I have managed to refer to them currently by passing them along to each new created form everytime (one by one) but wanted to refer to a variable from form 1 to say form 5, how can i do this? I read something about creating a Module..would that be just like creating forms instead and then all the variables will be global?

Thank you for any knowledge u can impart!
Which language are you using?
Making everything global is so un-OOP and you shouldn't do it. It really is a good sign of bad program design.
Oct 1 '07 #2
willywonka
18 New Member
i am using .net and created a window's application...i want to know how to reference variables across different forms (form 1 to form 5)so if u could please sugguest on how to do that.

Thanks.
Oct 1 '07 #3
r035198x
13,262 MVP
i am using .net and created a window's application...i want to know how to reference variables across different forms (form 1 to form 5)so if u could please sugguest on how to do that.

Thanks.
Which .NET language? VB, C#, J#?
You'll also need to explain what the variable does and it's purpose because that decides the best way of creating it.
e.g You could pass it as a parameter to a method, you could make it static in one of the classes, you could write its value to a file/socket and retrieve it in one of the other form's method, e.t.c (and there are other more exotic approaches). The correct approach depends on the context and purpose of the variable.
Oct 1 '07 #4
willywonka
18 New Member
thanks for ur assitance thus far...opps sorry i am using vb.net. i have created a few variable's which are the text entered into a text box in my 2nd form (someone's name, address, phone number). I then want to use these variables in my 5th form and also pass them as parameters to some methods that are called in the 5th form once a button is pressed. not sure how to access them, i have tried form1.name /name.form1 but have been extremley unsucessfully.
Oct 1 '07 #5
Frinavale
9,735 Recognized Expert Moderator Expert
thanks for ur assitance thus far...opps sorry i am using vb.net. i have created a few variable's which are the text entered into a text box in my 2nd form (someone's name, address, phone number). I then want to use these variables in my 5th form and also pass them as parameters to some methods that are called in the 5th form once a button is pressed. not sure how to access them, i have tried form1.name /name.form1 but have been extremley unsucessfully.

Check out this .NET article on Sessions - How to pass information between web pages.

Cheers
-Frinny
Oct 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jstaggs39 | last post by:
I want to create a Dcount and an If...Then...Else statement to count the number of records in a table based on the date that is entered to run the form. The If....Else statment comes in because if...
4
by: RSH | last post by:
Okay in my coninuing forms saga I have a situation where I am spawning a new form from my main form: ////////////////////////////////////////////////////////////////////////////////////// ...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
6
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
11
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
9
by: freeskier | last post by:
I am working on a form to edit student field placements. the student is selected from a combo box (cboStudent) which then populates a list box(lstPlacements) with field placements for that student....
3
by: 150563a | last post by:
I have a form that has 5 sub forms on it. I want to know how to reference the form properties of these sub forms. This I can do but what I am having trouble with is substituting the form name...
6
by: viperRider | last post by:
Another question to people smarter than me! LOL I have a form with a variable - Dim cboOriginator as TextBox - that holds the info about a textbox i click on. when i click on it, i have a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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
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
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
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 ...

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.