Please help in c++
-
How to link a radio button to a command button to get an answer in the edit box? example: a 3 radio buttons (10% discount, 5% penalty and 10% penalty) if supposing i will chose the first radio button (10% penalty) how to write the code so that by clicking the command button (compute) a result will be displayed in the edit box and wo with the other radio buttons? Im new in c++ Thank you so much. Neil
-
How to link a radio button to a command button to get an answer in the edit box? example: a 3 radio buttons (10% discount, 5% penalty and 10% penalty) if supposing i will chose the first radio button (10% penalty) how to write the code so that by clicking the command button (compute) a result will be displayed in the edit box and wo with the other radio buttons? Im new in c++ Thank you so much. Neil
I'm assuming you're using MFC. Make sure the radio buttons belong to the same group. You can do this by setting the group property of the first radio button to true. And the rest of the radio button must follow the first in order. Now associate an int variable with the first radio button by right clicking on it and selecting "Add Variable". Similarly associate an int variable with the edit box. In the button click handler, first call
UpdateData
. This will update the UI selection to the variables just added. Check the value of the radio button variable to determine the option selected. It will be 0 for first, 1 for second and so on. Do your calculation and set the result to the variable associated with the edit box. Finally callUpdateData(FALSE)
to set the variables back to the UI.«_Superman_» I love work. It gives me something to do between weekends.
-
I'm assuming you're using MFC. Make sure the radio buttons belong to the same group. You can do this by setting the group property of the first radio button to true. And the rest of the radio button must follow the first in order. Now associate an int variable with the first radio button by right clicking on it and selecting "Add Variable". Similarly associate an int variable with the edit box. In the button click handler, first call
UpdateData
. This will update the UI selection to the variables just added. Check the value of the radio button variable to determine the option selected. It will be 0 for first, 1 for second and so on. Do your calculation and set the result to the variable associated with the edit box. Finally callUpdateData(FALSE)
to set the variables back to the UI.«_Superman_» I love work. It gives me something to do between weekends.
Superman please show me sample code on how to do it? I can only compute the result under command button but when i select one radio button nothing will happend, i do not know how to connect radio button and command button to get the result. Please... neil
-
Superman please show me sample code on how to do it? I can only compute the result under command button but when i select one radio button nothing will happend, i do not know how to connect radio button and command button to get the result. Please... neil
Superman has given a very good explanation on how to implement this problem. Go Ahead and do the implementation. i am sure it is not a difficult task to complete. When you are stuck there are people to help you. On selecting the radio button you can pass the value to the function in the command button which does the calculation and display the result in the textbox.
-
Superman has given a very good explanation on how to implement this problem. Go Ahead and do the implementation. i am sure it is not a difficult task to complete. When you are stuck there are people to help you. On selecting the radio button you can pass the value to the function in the command button which does the calculation and display the result in the textbox.
thanks for the reply... my problem is that i dont have a sample code on how to pass the value of the function to the command button. If i tried to use if else statement the system will say syntax error :( here is my sample code: UpdateData(); if m_button1.Select = true m_edit2 = 0; else m_edit2 = m_edit1 * .9; UpdateData(false); i cant connect to the radio button...please help me... thank you and i will wait for a reply. neil
-
thanks for the reply... my problem is that i dont have a sample code on how to pass the value of the function to the command button. If i tried to use if else statement the system will say syntax error :( here is my sample code: UpdateData(); if m_button1.Select = true m_edit2 = 0; else m_edit2 = m_edit1 * .9; UpdateData(false); i cant connect to the radio button...please help me... thank you and i will wait for a reply. neil
C
Neil Jigger wrote:
how to pass the value of the function to the command button.
Create a Global variable. assign the value and then pass the value to the command button. and why are you using an if-else statement for this?
-
C
Neil Jigger wrote:
how to pass the value of the function to the command button.
Create a Global variable. assign the value and then pass the value to the command button. and why are you using an if-else statement for this?
hehehe...that's the reason why i posted this query because i only have little knowledge on c++. I am still on the process of studying this language. Please sir give me website to where i can look for sample codes on c++. I really need samples very badly... thank you again. neil
-
hehehe...that's the reason why i posted this query because i only have little knowledge on c++. I am still on the process of studying this language. Please sir give me website to where i can look for sample codes on c++. I really need samples very badly... thank you again. neil
Search radio button in Code Project. there are lots of examples. Check this link for example on Radio Button [^]
-
thanks for the reply... my problem is that i dont have a sample code on how to pass the value of the function to the command button. If i tried to use if else statement the system will say syntax error :( here is my sample code: UpdateData(); if m_button1.Select = true m_edit2 = 0; else m_edit2 = m_edit1 * .9; UpdateData(false); i cant connect to the radio button...please help me... thank you and i will wait for a reply. neil
Lose the calls to
UpdateData()
. They are completely unnecessary and only add to your confusion. You can easily have aCButton
member variable associated with each radio button, and can call the button'sGetCheck()
method to see if it is checked or not. BTW, when pasting code snippets, see #5 here. As it is, your code will not compile."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Lose the calls to
UpdateData()
. They are completely unnecessary and only add to your confusion. You can easily have aCButton
member variable associated with each radio button, and can call the button'sGetCheck()
method to see if it is checked or not. BTW, when pasting code snippets, see #5 here. As it is, your code will not compile."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
thanks david for your reply. i cannot continue with my code for the reason that i dont have enough knowledge on it. My code is successful if i will not use radio button in getting the reasult but when i used a radion button to connect to the command button i cannot successfully link to it coz i dont know the code on how to do it. I just need a sample code for my reference...can u send sample code to connect the radio button to a command button please...? Neil
-
thanks david for your reply. i cannot continue with my code for the reason that i dont have enough knowledge on it. My code is successful if i will not use radio button in getting the reasult but when i used a radion button to connect to the command button i cannot successfully link to it coz i dont know the code on how to do it. I just need a sample code for my reference...can u send sample code to connect the radio button to a command button please...? Neil
Neil Jigger wrote:
...used a radion button to connect to the command button...
What is this supposed to mean? What is a "command button?"
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons