MessageBox()中带数字 变量?
以下程序不能通过,为什么
//-------------------
int a=99;
Application->MessageBox("the number is "+IntToStr(a), NULL, MB_OKCANCEL)
//------------
问题点数:10、回复次数:3Top
1 楼Wingsun(孙春阳)回复于 2002-01-10 22:24:19 得分 5
当然不行啦!
MessageBox需要的是一个LPCSTR的参数,你给他的却是一个AnsiString的参数哦。
不如这样写:
int a=99;
Application->MessageBox(AnsiString("the number is "+IntToStr(a)).c_str(), NULL, MB_OKCANCEL);
或者:
int a=99;
char msg[256];
wsprintf(msg,"the number is %d",a);
Application->MessageBox(msg, NULL, MB_OKCANCEL);
这样快一些!
Top
2 楼belief888(信仰)回复于 2002-01-11 11:10:19 得分 1
楼上的说的对!他是高手啊Top
3 楼My_Love(浮萍)回复于 2002-01-11 11:37:17 得分 4
AnsiString Msg="the number is ";
Msg+=IntToStr(99);
Application->MessageBox(Msg.c_str(), NULL, MB_OKCANCEL);Top




