Converting textbox string to float?

后端 未结 2 610
臣服心动
臣服心动 2021-01-22 12:28

I\'m basically trying to write a basic converter in visual studio 2008, and I have 2 text boxes, one which gets input from the user, and one which gives output with the result.

2条回答
  •  耶瑟儿~
    2021-01-22 12:46

    Fixing it for you,

             String^ i1 = textBox1->Text;
             float rez = (float)(Convert::ToDouble(i1)*4.35);
             textBox2->Text = rez.ToString();
    

    Basically, you want to convert your string to an actual number, do the math, and then make it back into a string for displaying purposes.

提交回复
热议问题