Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Display only 2 digs in string in label.

Display only 2 digs in string in label.

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestion
16 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    That does not look like C++/CLI code to me; more like C#. I guess you didn't look too closely at the example code[^].

    Use the best guess

    S Offline
    S Offline
    Soren Lyder Nielsen
    wrote on last edited by
    #7

    I am using Microsoft Visual Studio 2010

    L 1 Reply Last reply
    0
    • S Soren Lyder Nielsen

      I am using Microsoft Visual Studio 2010

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #8

      And what is the relevance of that? You do realise that Visual Studio is a development environment and not a programming language?

      Use the best guess

      S 1 Reply Last reply
      0
      • L Lost User

        And what is the relevance of that? You do realise that Visual Studio is a development environment and not a programming language?

        Use the best guess

        S Offline
        S Offline
        Soren Lyder Nielsen
        wrote on last edited by
        #9

        Be cource the errorcodes I got was from MS Visual C++ 2010. I thought it might explain to you why I got thoose errorcodes in C++. Its C++ I am Using.

        L 1 Reply Last reply
        0
        • S Soren Lyder Nielsen

          Be cource the errorcodes I got was from MS Visual C++ 2010. I thought it might explain to you why I got thoose errorcodes in C++. Its C++ I am Using.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #10

          This is the C++/CLI forum; which are you using, C++/CLI or unmanaged C++?

          Use the best guess

          S 1 Reply Last reply
          0
          • L Lost User

            This is the C++/CLI forum; which are you using, C++/CLI or unmanaged C++?

            Use the best guess

            S Offline
            S Offline
            Soren Lyder Nielsen
            wrote on last edited by
            #11

            I have no idea. Thought I could get some help here ?

            L 1 Reply Last reply
            0
            • S Soren Lyder Nielsen

              I have no idea. Thought I could get some help here ?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #12

              Søren Lyder Nielsen wrote:

              I have no idea.

              Seriously? You are writing a program and you do not know what language or framework you are using? I don't know how you expect us to help if you cannot answer such a basic question. I would suggest you make a decision which language you plan to use and get hold of a book to learn the basics of it before trying anything else.

              Use the best guess

              S 1 Reply Last reply
              0
              • L Lost User

                Søren Lyder Nielsen wrote:

                I have no idea.

                Seriously? You are writing a program and you do not know what language or framework you are using? I don't know how you expect us to help if you cannot answer such a basic question. I would suggest you make a decision which language you plan to use and get hold of a book to learn the basics of it before trying anything else.

                Use the best guess

                S Offline
                S Offline
                Soren Lyder Nielsen
                wrote on last edited by
                #13

                Thanks for the help. But i gotta say, I feel it a is waste of time to try and get anything usefull out of you. All I ask for, is that you write one line of code with my own data in C++. But instead i feel you blame me for not knowing anything, even though that was one of the first things i told you. I will try my luck some other time.

                L 1 Reply Last reply
                0
                • S Soren Lyder Nielsen

                  Thanks for the help. But i gotta say, I feel it a is waste of time to try and get anything usefull out of you. All I ask for, is that you write one line of code with my own data in C++. But instead i feel you blame me for not knowing anything, even though that was one of the first things i told you. I will try my luck some other time.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #14

                  Søren Lyder Nielsen wrote:

                  All I ask for, is that you write one line of code with my own data in C++.

                  No, you have not asked that, you asked how to get a number formatted in a particular way in C++/CLI, and I referred you to the documentation that explains it in detail, with plenty of samples. It seems you are not prepared to spend the time reading it. You also do not seem to know exactly which language you are using, so I cannot answer the question, because it would be different for each language.

                  Søren Lyder Nielsen wrote:

                  But instead i feel you blame me for not knowing anything

                  Neither did I blame you for anything. I have done my best to help you but I cannot answer the question unless I get the proper facts to start with. As I said before, you need to decide which version of the language you are using and start studying it. Give us the proper facts and background to your problem and we will try to help, but you are expected to do some of the work for yourself.

                  Use the best guess

                  1 Reply Last reply
                  0
                  • S Soren Lyder Nielsen

                    Hey. I am trying to get my program to display only 2 decimals of the result og an calculation. Code:

                    // Defination af input
                    dansk = System::Convert::ToDouble(textBox2->Text);
                    kurs = System::Convert::ToDouble(numericUpDown1->Text);

                             // Udregningerne
                             tysk = dansk / kurs;
                             ti = tysk \* 0.90;
                             femten = tysk \* 0.85;
                             tyve = tysk \* 0.82;
                             bdansk = tysk \* kurs \* 1.25;
                             bti = tysk \* 0.90 \* 1.25;
                             bfemten = tysk \* 0.85 \* 1.25;
                             btyve = tysk \* 0.82 \* 1.25;
                             btysk = tysk \* 1.18;
                    
                             //konvertering til udskrivning af resultat
                             label7->Text = System::Convert::ToString(dansk) + " Kr";
                             label8->Text = System::Convert::ToString(ti) + " Kr";
                             label9->Text = System::Convert::ToString(femten) + " Kr";
                             label10->Text = System::Convert::ToString(tyve) + " Kr";
                             label14->Text = System::Convert::ToString(bdansk) + " Kr";
                             label15->Text = System::Convert::ToString(bti) + " Kr";
                             label16->Text = System::Convert::ToString(bfemten) + " Kr";
                             label17->Text = System::Convert::ToString(btyve) + " Kr";
                             label20->Text = System::Convert::ToString(tysk) + " Eur";
                             label21->Text = System::Convert::ToString(btysk) + " Eur";
                    

                    My ints are defined another place in my prpgram. Right now my result will be something like 54.867563547, and not 54.86, as my wish is. Can you help ?

                    U Offline
                    U Offline
                    User 9966263
                    wrote on last edited by
                    #15

                    1 - convert them to float type , example : { double a = 2.1589687489; String^ b = Convert::ToString((float)a); } 2 - remove them , example : { double a = 2.1589687489; String^ b = Convert::ToString(a); b = b->remove(b->IndexOf('.')+2 ); }

                    L 1 Reply Last reply
                    0
                    • U User 9966263

                      1 - convert them to float type , example : { double a = 2.1589687489; String^ b = Convert::ToString((float)a); } 2 - remove them , example : { double a = 2.1589687489; String^ b = Convert::ToString(a); b = b->remove(b->IndexOf('.')+2 ); }

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #16

                      There is no need to do that when you can use format strings to produce the required result in the first place.

                      Use the best guess

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups