| | |
Couldn't pass variable values to another form
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2007
Posts: 28
Reputation:
Solved Threads: 0
Hi there:
I defined several variables and assigned them values (nonzero) on a form. But I always got zero values of them when I cite them from another form. I am using BCB and never met this problem before even when I was doing the similar things. Can somebody give me hint on this? Thank you in advance!
Driplet
I defined several variables and assigned them values (nonzero) on a form. But I always got zero values of them when I cite them from another form. I am using BCB and never met this problem before even when I was doing the similar things. Can somebody give me hint on this? Thank you in advance!
Driplet
Are you sure you've declared those variables as public?
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Okay. Post the entire code if possible. The root cause of the problem may lie somewhere else rather than in the code you've given.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
•
•
Join Date: Oct 2006
Posts: 8
Reputation:
Solved Threads: 0
simply define your variables on form1 and then redefine then with the extern parameter on form2. like this...
<form1>
int kids = 2, dogs = 1;
<form2>
extern int kids;
extern int dogs;
Label1->Caption = IntToStr(dogs);
Label2->Caption = IntToStr(kids);
That should solve your issue in BCB2006
http://www.sscnet.ucla.edu/geog/gess...nd/windows.htm
Also if you are setting the variables after you make the other form visible, you will not be able to pass the variable until it is reopened...
Like this:
options = 2;
fmAdd->Visible = true;
fmStudent->Visible = false;
Good luck
<form1>
int kids = 2, dogs = 1;
<form2>
extern int kids;
extern int dogs;
Label1->Caption = IntToStr(dogs);
Label2->Caption = IntToStr(kids);
That should solve your issue in BCB2006
http://www.sscnet.ucla.edu/geog/gess...nd/windows.htm
Also if you are setting the variables after you make the other form visible, you will not be able to pass the variable until it is reopened...
Like this:
options = 2;
fmAdd->Visible = true;
fmStudent->Visible = false;
Good luck
Last edited by MrGobroski; Jul 5th, 2008 at 10:05 pm. Reason: missed some code
![]() |
Similar Threads
- text field values to php variable....... (PHP)
- Taking Values from another form to Table layout panel ("How?") (VB.NET)
- pass the value to the text box (JavaScript / DHTML / AJAX)
- How to pass a whole table to another form? (Visual Basic 4 / 5 / 6)
- How do I pass values from a called form to a calling forms variables? (C++)
- submiting info into a database for retrieval! (PHP)
- Sorting in date order (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: can i get the full file path from specified file name (.exe)
- Next Thread: Playing sound file, Microsoft Visual c++ 2008
Views: 1113 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






