Hi guys, good day!
I have a question here pertaining to Visual C++ graphics based. I recently started out incorporating GUI into my C++ programs, in this case, a calculator.
I have a textbox named TextBox1, the user enters the numbers and operators inside it, and when the button is clicked, it outputs the result. Here is a sample input;
when the user clicks the button, it outputs 6 into a label.
Problem is, I could not obviously use cin here to get the numbers and store into my variables. Can someone show me a very simple code as to how to store 4 and 2 into my variables num1 and num2 and also, store the operator "+" into my variable "operation" of char data type.

Something like this;

double num1, num2;
double result;
num1 = TextBox1->Text; //here is the error
result = num1 + num2;
label1->text = "" + result;

3 Years
Discussion Span
Last Post by ddanbe

I guess it is not your intention to "parse" an "expression".
So I suggest to use two textboxes. One for num1, the other for num2.
Next use an operator button(+,-,. . .)
and using the suggestion by Moschops to update your label text.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.