473,809 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

value in the variable expires

I have 2 forms. in form1 i declared a public variable in which a value is
stored. then i goto form2 . (for this is create an object of form2 in form1.)
when i go to form2 there is call form1. when i come to form1 the value stored
in the variable decalred in form1 gets lost. how can i retain those values?
Apr 10 '06 #1
3 1343
SP
"Vijay" <Vi***@discussi ons.microsoft.c om> wrote in message
news:AA******** *************** ***********@mic rosoft.com...
I have 2 forms. in form1 i declared a public variable in which a value is
stored. then i goto form2 . (for this is create an object of form2 in
form1.)
when i go to form2 there is call form1. when i come to form1 the value
stored
in the variable decalred in form1 gets lost. how can i retain those
values?


First forms are just classes like most things in .Net. It would seem that
you need to pass a reference of form1 to form2 so that from form 2 you can
access the public variable.

public class Form2 : Form
{
public Form2(Form1 form1)
{
form1.YourPubli cVariable ....
}
}

SP
Apr 10 '06 #2
should i pass them to the next form and get them again to the first form in
order to reatin them.?

"SP" wrote:
"Vijay" <Vi***@discussi ons.microsoft.c om> wrote in message
news:AA******** *************** ***********@mic rosoft.com...
I have 2 forms. in form1 i declared a public variable in which a value is
stored. then i goto form2 . (for this is create an object of form2 in
form1.)
when i go to form2 there is call form1. when i come to form1 the value
stored
in the variable decalred in form1 gets lost. how can i retain those
values?


First forms are just classes like most things in .Net. It would seem that
you need to pass a reference of form1 to form2 so that from form 2 you can
access the public variable.

public class Form2 : Form
{
public Form2(Form1 form1)
{
form1.YourPubli cVariable ....
}
}

SP

Apr 10 '06 #3
SP

"Vijay" <Vi***@discussi ons.microsoft.c om> wrote in message
news:44******** *************** ***********@mic rosoft.com...
should i pass them to the next form and get them again to the first form
in
order to reatin them.?
First ask yourself if the public variable on Form1 really belongs to Form1.
Perhaps you should be passing a class that holds this variable to each of
your forms. What is this public variable? Is Form1 the main form of your
application so it will always be instansiated?

SP

"SP" wrote:
"Vijay" <Vi***@discussi ons.microsoft.c om> wrote in message
news:AA******** *************** ***********@mic rosoft.com...
>I have 2 forms. in form1 i declared a public variable in which a value
>is
> stored. then i goto form2 . (for this is create an object of form2 in
> form1.)
> when i go to form2 there is call form1. when i come to form1 the value
> stored
> in the variable decalred in form1 gets lost. how can i retain those
> values?


First forms are just classes like most things in .Net. It would seem that
you need to pass a reference of form1 to form2 so that from form 2 you
can
access the public variable.

public class Form2 : Form
{
public Form2(Form1 form1)
{
form1.YourPubli cVariable ....
}
}

SP

Apr 10 '06 #4

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

Similar topics

3
8905
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
3
18242
by: otto | last post by:
i need to read a variable in a javascript and translate it to a form in html the javascript variable is: <SCRIPT LANGUAGE='JavaScript'>RF2N('Total');</script> and i need to put that variable as the value in this line <input type="hidden" name="AMT" value="**">
1
5540
by: koen colen | last post by:
Hello group, I hope you guys can help me out, I am modifying a piece of code from Joe Norman, I did found the code here: http://www.intranet2internet.com/public/default.asp?PAGE=sscript&ID=3 My question: How can I save the value's of a form to a cookie, but in the textarea's of that form the "hard returns" must be saved with it?
3
2594
by: chirs | last post by:
Hi, I want to put a value in a cookie. The following code does not work. It does not store the box1.value in the cookie. How can I fix it? <input type="text" name="box1" onblur=document.cookie="user=" + box1.value> Chris
3
12401
by: Enoch Chan | last post by:
I would like to set a Session variable to a value. In Vbscript it should be Session("ZoomValue")=500 How can I set this session variable by using Javascript? Thanks
1
1790
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open the second page using Window.Open with the values being passed to the second page by a global variable created in a Module added to the project, by the use of an Application variable and by the use of a session variable. In the page load of the...
0
1257
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open the second page using Window.Open with the values being passed to the second page by a global variable created in a Module added to the project, by the use of an Application variable and by the use of a session variable. In the page load of the...
0
1828
by: JT | last post by:
I posted a question earlier about communicating between a javascript function and vb.net. In the end I decided to try using a cookie. I use the following javascript function (from vb.net) to set the cookie: sb.Append("<script language='javascript'>") sb.Append("{if (confirm('Are you sure? ') == true)") sb.Append("{var date = new Date(); date.setTime(date.getTime()+(60*60*1000)); var expires = ' expires='+date.toGMTString();...
8
1950
by: Doru Roman | last post by:
Hi, I insert a new record with a command: private SqlCommand comInsert; comInsert = conDataBase.CreateCommand(); comInsert.CommandType = CommandType.Text;
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
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 we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.