如何将 wxString 转换为 Int 以使用算术运算?
我是 Wxsmith 和 C++ 的新手 我创建了一个带有 2 个文本框、一个静态文本和一个按钮的基本 UI。问题是如何添加在两个文本框中输入的 2 个值,并在单击按钮时将其显示在静态文本中? 在 Visual Basic 中,您所要做的就是:
variable = Val(textbox1.text)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的任务可以自然地分为两部分:
安排以便在按下按钮时执行某些代码。
编写按下按钮时要执行的代码。
从您的问题中并不清楚您需要其中哪些方面的帮助。也许两者都有?
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?
我不熟悉wxwidgets,但是wxString有一个ToLong成员函数: http://docs .wxwidgets.org/stable/wx_wxstring.html#wxstringtolong
看来这试图将字符串转换为 long 并将其存储在提供的位置,返回 true 或 false 来指示它是成功还是失败。
我注意到似乎没有直接转换为 int 的版本。
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.
I note there doesn't seem to be a version for converting directly to int.