Hallo i try to convert the value from the textbox to float i use this code :
float a;
if(rb1->Checked){a=Convert::ToFloat(tb1->Text);tb26->Text=Convert::ToString(a);}
Well, putting all that code on one line is not a good idea for starters
But to answer your question properly, you need to give us more details as to what problem you are having.
Actually, there is no such function as Convert::ToFloat(). The "official" .NET name of that type is Single, and float is just an alias name for that type in C++/CLI (and, AFAIK, in C#). Consequentially, the function you need to call is Convert::ToSingle().
Also, as already has been pointed out, putting all that code on a single line without a single whitespace is no good idea with regard to coding style, though of course it doesn't keep the code from compiling successfully.
Not quite simple.
You can use atof or any other CRT function in managed C++/CLI, but you have to "scratch your had with the foot".
Something like this:
Much easier and correct is to use the "managed way", like Eri already suggested:
Code:
float fValue = Convert::ToSingle(textBox1->Text);
So...
When in Rome, do as the Romans do!
In other words, when in managed C++/CLI, do as .NET programmers do.
@Pavaka:
I'm just curious...
Is your IntelliSense tool out of order and is showing Convert::ToFloat method?
Also, have you lost the Internet connection with MSDN Library?
[ Moved thread ]
Last edited by ovidiucucu; March 17th, 2012 at 04:43 AM.
Bookmarks