Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:45:54+00:00 2026-05-13T09:45:54+00:00

I have a numeric up down, and I want it to either add or

  • 0

I have a numeric up down, and I want it to either add or subtract one depending on if the up or down arrow is pressed. I have the code below, but it only works to subtract one from the variable.

  Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        If ComboBox1.SelectedIndex = 0 Then
            seatsA = seatsA - 1
            TextBox2.Text = seatsA
        ElseIf ComboBox1.SelectedIndex = 1 Then
            seatsB = seatsB - 1
            TextBox2.Text = seatsB
        ElseIf ComboBox1.SelectedIndex = 2 Then
            seatsC = seatsC - 1
            TextBox2.Text = seatsC
        End If
End Sub

Edit: If the numeric updown value is changed, the variable stores this change, each comboBox has its own variable as it needs to store the value for each. I.e., if seatsA is 20, when the user goes back to selected index one 20 is shown.

Seats start with a number…such as 75, when the numeric updown is increased, one is taken off the seats value for each seat (a,b,c)

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:45:55+00:00Added an answer on May 13, 2026 at 9:45 am

    Do you want TextBox2 to have the same value as NumericUpDown1? If it’s the case, you can simply do this:

    Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
            TextBox2.Text = NumericUpDown1.Value
    End Sub
    

    Edit:

    From what I understand of your edit, what you want to do here is set the correct value to your NumericUpDown when the selected index changes. You can do something like this:

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ComboBox1.SelectedIndex = 0 Then
                NumericUpDown1.Value = seatsA
            ElseIf ComboBox1.SelectedIndex = 1 Then
                NumericUpDown1.Value = seatsB
            End If
    End Sub
    

    Then to save a value change, you could do something like:

    Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
            If ComboBox1.SelectedIndex = 0 Then
                seatsA = NumericUpDown1.Value
            ElseIf ComboBox1.SelectedIndex = 1 Then
                seatsB = NumericUpDown1.Value
            End If
    End Sub
    

    Other edit:

    OK… I understand what you’re trying to do now…

    I can think of two strategies:

    1. In your form, have a LastNumericUpDownValue member in which you keep the last value of the numericupdown. Then you compare the current value to the last value, and you’ll know if the value has been incremented or decremented.

    2. Keep the original number of seats as a member of the form when you load the form. Then when the NumericUpDownValue1 changes you can calculate that seatA = originalNumberOfSeats – seatsRequired (the value of NumericUpDown1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table with a large number of rows and one numeric
I'm building a simple slideshow using jQuery. I have the basics down, but as
I have a numeric textbox in C# .NET which is nothing more than a
I have a list of numeric values. I may normalize the values if needed.
I have 2 fields in the database month (numeric) and year (numeric) and I
I have a table on SQL2000 with a numeric column and I need the
I have a Python function that takes a numeric argument that must be an
I have a rails application which is still showing the cachebusting numeric string at
I have an experiment streaming up 1Mb/s of numeric data which needs to be
Say I have a string of 16 numeric characters (i.e. 0123456789012345) what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.