如何在标签中显示变量值? [英] How do I display a variables value in a label?

查看:659
本文介绍了如何在标签中显示变量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问了2个多问题的帖子,其中一个问题是如何在标签中显示变量值?",但我却没有得到答案.
现在是我的问题,如何在标签中显示变量名称?
例如,如果我想显示以下内容:
我要显示数字10是因为我想这么做"
其中数字10是变量值.
在DOS窗口中,我会这样写:

I''ve asked 2 multiple-question posts and one of those questions has been "how do I display a variables value in a label?", but I never got an answer to that.
Now that is my question, how do I display a variables name in a label?
For example if I want to display something like this:
"Im showing the number 10 because I want to"
where the number 10 is a variables value.
In a DOS window I would write it like this:

int main()
{
int Number = 10;
cout << "Im showing the number " << Number << " because I want to";
return 0;
}



但是,如何在标签(Windows应用程序内部)中做到这一点?

谢谢你! :)



But how can I do it in a label (inside a Windows Application)?

Thank You! :)

推荐答案

label.Text = sprintf("I'm showing the number %d because I want to.", Number);


如果我理解您的问题比起正确的方法,您必须先将整数值转换为字符串,然后使用SetWindowText将字符串显示为标签.

:)
If I understood your problem properly than first you have to convert the integer value to string and using SetWindowText you display that string to label.

:)


这篇关于如何在标签中显示变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆