can not run it on my computer"<---it is can not running on Visual C++.
Yes, I am also think the error on "ToInt32(0)". However, Thanks for you
RickyChan wrote:
Dear David,
Thanks for you reply! I have following the book to write the program, it
is show follow;
-----------------------------------------------------------------------------------------------------------------------------------
private: System::Void txtQty_TextChanged(System::Object^ sender,
System::EventArgs^ e) {
int n500, n100, n50, n10, n1, amt, change;
try
{
amt=txtPrice->Text->ToInt32(0)*txtQty->Text->Text->ToInt32(0);
txtSum->Text=amt.ToString();
txtChange->Text=(txtPay->Text->ToInt32(0)-amt).ToString();
change=txtChange->Text->ToInt32(0);
n500=change/500;
change%=500;
n100=change/100;
change%=100;
n50=change/50;
change%=50;
n10=change/10;
change%=10;
lbl500->Text=n500.ToString();
lbl100->Text=n100.ToString();
lbl50->Text=n50.ToString();
lbl10->Text=n10.ToString();
lbl1->Text=n1.ToString();
}
catch(Exception *err)
{
return;
}
}
-----------------------------------------------------------------------------------------------------------------------------------
ToInt32(0)<------ From book explain, it is a 32-bit Integer when I input
the number, but I can not run it on my computer.
The book is Visual C++ 2003. Can it running on Visual C++ 2008? If no,
please give my any suggestion!
Ricky:
this is a question on managed C++ (.NET framework) so you would be better
to ask it in the
microsoft.public.dotnet.languages.vc
newsgroup, or in the MSDN VC forum at
<http://forums.msdn.microsoft.com/en-US/vcgeneral/threads/>
You say your book in Visual Studio 2003, but you are using VS2008. The
syntax for managed C++ was changed in VC2005, and your code appears to use
that syntax (which is called C++/CLI). So your VS2003 book will not help
you.
I would certainly recommend that you get a book on C++/CLI if you want to
use it However I would also recommend that you consider carefully whether
C++/CLI is the way you want to go; for most people using C# is a much
better way to target the .NET framework.
As to your question, I am not an expert on managed coding, but it seems to
me that you are not using the ToInt32() method correctly.
What do you mean by "but I can not run it on my computer"? When you have a
problem, you need to describe exactly what happened, and what you had
expected to see.
--
David Wilkinson
Visual C++ MVP