CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2010
    Posts
    112

    Print int on msgbox

    Here's the code:


    MessageBox(NULL, I want to print int here, "caption", MB_ICONERROR);


    how to convert int or DWORD or BYTE.....and print it on msgbox?

    I know that it demands LPCSTR string as that parametar to print it.So how to convert it right there in order to print its value?

    This should be an easy question.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Print int on msgbox

    There are several ways to convert ints to strings. Pick one and use it before the messagebox call.

  3. #3
    Join Date
    Feb 2010
    Posts
    112

    Re: Print int on msgbox

    Can I get more info?

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Print int on msgbox

    Here is an example:
    Code:
    int i = 42;
    CString str;
    str.Format(_T("%d"), i);
    
    MessageBox(NULL, str, _T("caption"), MB_ICONERROR);
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Feb 2010
    Posts
    112

    Re: Print int on msgbox

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured