Get value from NumericUpDown

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Re: Get value from NumericUpDown

Postby ger21 » Fri Jan 11, 2019 7:52 pm

What is the error you are seeing?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Get value from NumericUpDown

Postby Jeffsg605 » Fri Jan 11, 2019 8:06 pm

I think you hit the main ones. That would be great.

So I assume there's no way to read in the value from a NumericUpDown yet?
Jeffsg605
 
Posts: 16
Joined: Fri Jan 11, 2019 5:20 pm

Re: Get value from NumericUpDown

Postby Robertspark » Fri Jan 11, 2019 8:30 pm

Jeffsg605 wrote:So I assume there's no way to read in the value from a NumericUpDown yet?



give me a moment.... multitasking
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Get value from NumericUpDown

Postby Robertspark » Fri Jan 11, 2019 8:55 pm

Use one of these below (numericUpDown1.Value is actually a Decimal value)

Code: Select all
      double dblnumericUpDown1 = Convert.ToDouble(numericUpDown1.Value);
      string strnumericUpDown1 = Convert.ToString(numericUpDown1.Value);
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Get value from NumericUpDown

Postby dezsoe » Fri Jan 11, 2019 9:25 pm

You should save it in the ValueChanged event, I think.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Get value from NumericUpDown

Postby Robertspark » Fri Jan 11, 2019 9:28 pm

dezsoe wrote:You should save it in the ValueChanged event, I think.


Not necessary, if you are using another event like within a button event..... Depends what your form does.... If you want the value to have instant effect on change then yes
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Get value from NumericUpDown

Postby Jeffsg605 » Sat Jan 12, 2019 2:24 pm

Thank you guys. I'll try both methods. I could have sworn I tried the "Convert.ToDouble(...)" but it didn't work. Maybe I typed it wrong.

In any case, I'll be back at the machine on Monday. I'll let you know, thanks for all the help!
Jeffsg605
 
Posts: 16
Joined: Fri Jan 11, 2019 5:20 pm

Re: Get value from NumericUpDown

Postby cncdrive » Sat Jan 12, 2019 10:20 pm

Things should work, because the UCCNC is using the .NET compiler called (CodeDom), so there is no way that C# functions like Convert.ToDouble is not working, because that would mean that the .NET framework is broken on the computer, but that is also not possible, because then the UCCNC itself would also not work, because it is a .NET application and run by the .Net framework. :)
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Get value from NumericUpDown

Postby Jeffsg605 » Sat Jan 12, 2019 10:22 pm

That was my understanding, too. But then how come something like "double x = (double)NumericUpDown1.Value" doesn't work.
Jeffsg605
 
Posts: 16
Joined: Fri Jan 11, 2019 5:20 pm

Re: Get value from NumericUpDown

Postby cncdrive » Sat Jan 12, 2019 10:29 pm

It should work. What is the error message you get?
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

PreviousNext

Return to Macros

Who is online

Users browsing this forum: No registered users and 10 guests