Using NumericUpDown input

RedRuffing15

New member
Joined
May 13, 2009
Messages
2
Programming Experience
1-3
Hey everyone, Im somewhat new to VB and Im having trouble with a simple program. I have a NumericUpDown control with a range of 10-50 and I want to have the selected number be multiplied by an amount of money to create yearly cost. I dont know, however, how to use inputted data from the NumericUpDown control in a statement because I cannot convert it to Integer and I also dont know how to call in the data even if a number is selected.

Is there a way to do this or is it even possible? Thanks!
 
VB.NET:
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        Dim int As Integer
        int = NumericUpDown1.Value
    End Sub

is this what your looking for?
 
NUD's (NumericUpDown) have a value property you use to get the number and you can multiply it by other numbers. Since you're talking yearly costs I'd recommend using Decimals instead of Integers and the NUD's Value property is a Decimal variable anyways.
 
VB.NET:
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        Dim int As Integer
        int = NumericUpDown1.Value
    End Sub

is this what your looking for?

Thats Great!! Thats the first leway I made in making it work. The only issue I have with that now is I have all the code go into action with a btnCalculate_Click Private Sub and to have a Private Sub for the NumericUpDown, the selected data wont 'transfer' into the Calculate Buttons sub, is there a way to transfer the int from the NumericUpDown1 Sub to the btnCalculate_Click Sub so that the calculations dont start until I press Calculate? I'm new with VB so I tried putting it in a Function, but that didn't work and just putting
VB.NET:
int = NumericUpDown1.Value
doesn't work without the (ByVal sender As System......
 
Back
Top