messagebox输出字符串加变量

解决方案 »

  1.   

    int a=3;
    char F[10]; 
    itoa(a,F2, 10);
    CString str=F2;
    AfxMessageBox("楼主今年"+str+"岁");
      

  2.   

    CString str(_T("媳妇"));
    CXXXDlg::OnButton1()
    {
      GetDlgItemText(IDC_EDIT1,str);
      const char *array = "楼主是你的";
      char *buf = new char(20);
      sprintf(buf, "%s%s", array, (LPCTSTR)str);
      MessageBox(buf, "告示", MB_OK);
    }
      

  3.   

    CString str="你好!"
    int number=8;
    CString strNumber;
    strNumber.Format("%d",number);
    str=str+strNumber;
    MessageBox(str);
      

  4.   


    换行么?
    "\n"或者"\r\n"就行
    str=str+strNumber+"\r\n";
      

  5.   

    CString strText;
    strText.Format();格式化以后再AfxMessageBox输出
    AfxMessageBox(strText);
      

  6.   

    用ShellMessageBox吧
    ShellMessageBox(hInst, hWnd, TEXT("楼主你好,这是第%1!d!楼, %2!s!", TEXT("TITLE"), MB_OK, 8, TEXT("string"));
      

  7.   

    int a=2011;
    CString str;
    str.Format("%d",a);AfxMessageBox(str);
      

  8.   


    CString address = "湖南省长沙市***镇***街**号";
    CString stryear = "";
    int year = 18;
    stryear.Format("%d",year);
    AfxMessageBox("楼主地址:"+address+";楼主芳龄:"+stryear+"岁");
      

  9.   

    format 你想怎么搞就怎么搞