CLR - System::Decimal or Int32 to int

Started by
4 comments, last by jpetrie 15 years, 9 months ago
Hi, I am having a problem trying to convert a value from a System.Windows.Forms.NumericUpDown.Value to an int. I have tryed a number of methods to cast the decimal in some way to an int, however it will not cast so easily. I have tryed the method NumericUpDown.Value::ToInt32, but even this is giving me an error, the error code mentions something to do with the CLR, Does anyone know of a simple solution? Thanks
---Terence Burns---
Advertisement
Casting should work fine in most circumstances, as long as you're not unboxing directly into a value of the opposing type (which should not be the case here). Post your code, you're likely doing something else wrong.
Hi,

int ButtonX = (int)UpDownX->Value.ToInt32();int ButtonY = (int)UpDownY->Value.ToInt32();ButtonManager->CreateButton( "..\\reset_normal.bmp", ButtonX, ButtonY, Normal );


the button manager takes 2 ints for positioning

Thanks

[Edited by - terry_burns85 on July 8, 2008 11:52:39 AM]
---Terence Burns---
Having parens in your function calls would probably be a good start.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Promit
Having parens in your function calls would probably be a good start.


sorry, parens?

--edit--
of after the ToInt32(), yea i shoulda had them there, sorry i just typed the code from memory.
---Terence Burns---
So is that actual code, or from-memory code? Because the latter is not useful to anybody. Post the actual code and ideally the actual error message.

Have you stepped through this in a debugger? Are you sure UpDownX isn't null, for example?

This topic is closed to new replies.

Advertisement