Question NumericUpDown Question

pyromark

New member
Joined
Nov 13, 2013
Messages
4
Programming Experience
Beginner
Im making a pizza menu, btnSmall is 6.00$. I want it so that multiplies by whatever number is shown on the numericupdown. I have to so it shows 6.00$ in my label but when i try order two pizzas, it still says 6.00$.. heres the code. some help please!! :)

Public Sub btnSmall_Click(sender As Object, e As EventArgs) Handles btnSmall.Click
lblSmall.Text = CStr(dblbtnsmall * 1)
lblSmall.Text = CStr(dblbtnsmall * NumericUpDown1.Value)
lblSmall.Text = dblbtnsmall.ToString("c")
 
sorry the code actually is

Public Sub btnSmall_Click(sender As Object, e As EventArgs) Handles btnSmall.Click
lblSmall.Text = CStr(dblbtnsmall * NumericUpDown1.Value)
lblSmall.Text = dblbtnsmall.ToString("c")
 
Hi and welcome to the Forum,

Since you are running code from a Button I am guessing that you have not incremented the NumericUpDown control. Give this a try instead:-

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  Const dblbtnsmall As Double = 6D
  NumericUpDown1.Value += NumericUpDown1.Increment
 
  lblSmall.Text = (dblbtnsmall * NumericUpDown1.Value).ToString("c")
End Sub

Also notice that I only set the Label's Text property once and once only.

Hope that helps.

Cheers,

Ian
 
That works but when i click the numericupdown to 5 and hit the small button, it moves it to 6. so how do i make it so that when i move it to 5 & hit the small button i want it to stay on 5
 
Hi,

That works but when i click the numericupdown to 5 and hit the small button, it moves it to 6. so how do i make it so that when i move it to 5 & hit the small button i want it to stay on 5

That means that my initial assumption was slightly incorrect so what do you think you can remove from my code example to Stop the NumericUpDown control from INCREMENTING when you press the Small Button?

Cheers,

Ian
 
Back
Top