Sign in to follow this  

CLR - System::Decimal or Int32 to int

This topic is 3480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Having parens in your function calls would probably be a good start.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this