| | |
How do I pass values from a called form to a calling forms variables?
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2007
Posts: 18
Reputation:
Solved Threads: 0
I am relatively new to Borland 2006 C++ Builder. I have a form which has about 6 buttons and a text box for selecting and inputting values respectively (e.g. Clicking on Button 1 should return "100" to a variable in the calling form. Likewise, entering 100 into the text box and pressing enter would do same. I have been able to return values from the text box e.g.
However, I need help on how to return values to the calling forms variable when a user clicks one of the buttons instead of entering text in the text box.
Thanks in advance.
C++ Syntax (Toggle Plain Text)
String amt = frmChoice->TxtBxt1->Text
Thanks in advance.
•
•
Join Date: Jun 2007
Posts: 18
Reputation:
Solved Threads: 0
Thanks for your help Narue. Since I am closing the called form with the code
once one of the buttons is clicked or the OK button is used to pass the text typed in the input box,
can I assign the appropraite value to a variable that has a visibility within the whole called form in all the buttonclick events and then pass the value within the variable in the OnClose() event of the called Form?
Thanks.
C++ Syntax (Toggle Plain Text)
this->close()
can I assign the appropraite value to a variable that has a visibility within the whole called form in all the buttonclick events and then pass the value within the variable in the OnClose() event of the called Form?
Thanks.
•
•
Join Date: Jun 2007
Posts: 18
Reputation:
Solved Threads: 0
Yes, I am using WinForms on a Win32 development platform. The code for the calling form is as follows:
The code above loads the form which allows the user to click a button to select the desired amount.
The code below is that of the called form.
c_amt is a global variable within the called form.
Thanks. I really appreciate your help.
C++ Syntax (Toggle Plain Text)
void __fastcall TfrmClient::btnRechargeClick(TObject *Sender) { // Increment Transaction Number transaction_no++; frmAmountSelector->Show(); // *** where I got stuck trying to pass c_amt from the other form***
The code below is that of the called form.
C++ Syntax (Toggle Plain Text)
void __fastcall TfrmAmountSelector::btn100Click(TObject *Sender) { c_amt = "100"; this->Close(); } //--------------------------------------------------------------------------- void __fastcall TfrmAmountSelector::btn200Click(TObject *Sender) { c_amt = "200"; this->Close(); } //--------------------------------------------------------------------------- void __fastcall TfrmAmountSelector::btn500Click(TObject *Sender) { c_amt = "500"; this->Close(); } //--------------------------------------------------------------------------- void __fastcall TfrmAmountSelector::btn1000Click(TObject *Sender) { c_amt = "1000"; this->Close(); } //--------------------------------------------------------------------------- void __fastcall TfrmAmountSelector::btn2000Click(TObject *Sender) { c_amt = "2000"; this->Close(); } //--------------------------------------------------------------------------- void __fastcall TfrmAmountSelector::btn5000Click(TObject *Sender) { c_amt = "5000"; this->Close(); }
c_amt is a global variable within the called form.
Thanks. I really appreciate your help.
![]() |
Other Threads in the C++ Forum
- Previous Thread: is it worth learning vc++ 6.0?
- Next Thread: why link error
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






