Reputation: 675
I am new to Wxsmith and C++ I have created a basic UI with 2 text boxes, a static-text and a button. The question is how do i add the 2 values entered in the two text boxes and display it in the static-text when the button is clicked ? In visual Basic all you had to do was :
variable = Val(textbox1.text)
Upvotes: 1
Views: 2653
Reputation: 20616
Your task can be divided naturally into two parts:
Arranging so that certain code is executed when the button is pressed.
Writing the code to be executed when the button is pressed.
It is not clear from your question which of these you require help with. Perhaps both?
Upvotes: 0
Reputation: 19777
I'm not familiar with wxwidgets, but wxString has a ToLong member function: http://docs.wxwidgets.org/stable/wx_wxstring.html#wxstringtolong
It seems this attempts to convert the string to a long and store it in a location provided, returning true or false to indicate whether it succeeded or failed.
// Created a string up here somewhere
long converted;
if ( myString.ToLong (&converted) )
{ /* Do something with the number */ }
else
{ /* It wasn't a valid number */ }
I note there doesn't seem to be a version for converting directly to int.
Upvotes: 4