Display a number in a MessageBox

This is a discussion on Display a number in a MessageBox within the C++ Programming forums, part of the General Programming Boards category; I am trying to display myValue in the MessageBox. I use C++ 2008. How is this possible. It seems that ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    Display a number in a MessageBox

    I am trying to display myValue in the MessageBox. I use C++ 2008.
    How is this possible. It seems that MessageBox in this case only can display a string, "".


    int myValue = 0;
    double myVal2 = 3.14;
    myValue = myVal2;

    MessageBox::Show(myValue);

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would guess stringstream.
    Untested, because I'm lazy:
    Code:
    std::string myValue;
    std::stringstream myValueSS;
    myValueSS << myVal2;
    myValue = myValueSS.str();

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Please don't cross-post.
    Show a number in the MessageBox
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  2. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21