Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Numericupdown

Numericupdown

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shaahinm
    wrote on last edited by
    #1

    hi, I have a numericupdown control, I want users be able to increase its value by 0.15 (15 minutes) and when it reaches 60 it becomes 1, actually it works but only when user increase it, for example if its 1.30 and user decrease it it will be 0.85, I know my code has problem but I dont know how to solve it can someone help me?

    A L 2 Replies Last reply
    0
    • S Shaahinm

      hi, I have a numericupdown control, I want users be able to increase its value by 0.15 (15 minutes) and when it reaches 60 it becomes 1, actually it works but only when user increase it, for example if its 1.30 and user decrease it it will be 0.85, I know my code has problem but I dont know how to solve it can someone help me?

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      Shaahinm wrote:

      can someone help me?

      Only if you post your code. Alan.

      S 1 Reply Last reply
      0
      • A Alan N

        Shaahinm wrote:

        can someone help me?

        Only if you post your code. Alan.

        S Offline
        S Offline
        Shaahinm
        wrote on last edited by
        #3

        Dim s As Decimal = 0.6
        Private Sub nupS_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nupS.ValueChanged
        If (nupS.Value Mod s) = 0 Then
        nupS.Value = CDec(CInt(nupS.Value))
        s += 1
        End If
        End Sub

        1 Reply Last reply
        0
        • S Shaahinm

          hi, I have a numericupdown control, I want users be able to increase its value by 0.15 (15 minutes) and when it reaches 60 it becomes 1, actually it works but only when user increase it, for example if its 1.30 and user decrease it it will be 0.85, I know my code has problem but I dont know how to solve it can someone help me?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          And what is the problem? if you set the step value to 0.15 it would increment like so:

          0.00
          0.15
          0.30
          0.45
          0.60 assume this magically changes into 1.00
          1.15
          1.30
          1.45
          1.60 magic required ==> 2.0

          and decrement like this:

          2.30
          2.15
          2.00
          1.85 assume this magically changes into 1.45
          1.30
          1.15
          1.00
          0.85 magic required ==> 0.45
          0.30
          0.15
          0.00

          So all that is needed is two lines of code, according to these rules: if fraction==0.60 add +0.40 if fraction==0.85 add -0.40 Put something to that effect inside the valuechanged handler. Warning: if the control would allow a paste, all kinds of nasty things could happen... :)

          Luc Pattyn

          :badger: :jig: :badger:

          Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

          :jig: :badger: :jig:

          S 1 Reply Last reply
          0
          • L Luc Pattyn

            And what is the problem? if you set the step value to 0.15 it would increment like so:

            0.00
            0.15
            0.30
            0.45
            0.60 assume this magically changes into 1.00
            1.15
            1.30
            1.45
            1.60 magic required ==> 2.0

            and decrement like this:

            2.30
            2.15
            2.00
            1.85 assume this magically changes into 1.45
            1.30
            1.15
            1.00
            0.85 magic required ==> 0.45
            0.30
            0.15
            0.00

            So all that is needed is two lines of code, according to these rules: if fraction==0.60 add +0.40 if fraction==0.85 add -0.40 Put something to that effect inside the valuechanged handler. Warning: if the control would allow a paste, all kinds of nasty things could happen... :)

            Luc Pattyn

            :badger: :jig: :badger:

            Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

            :jig: :badger: :jig:

            S Offline
            S Offline
            Shaahinm
            wrote on last edited by
            #5

            thank you man, the problem is that I am not able to find out whether user is increasing the value or decreasing it Should I store its value and check it when the value changed??? or is it possible to use delegates and events.

            L 1 Reply Last reply
            0
            • S Shaahinm

              thank you man, the problem is that I am not able to find out whether user is increasing the value or decreasing it Should I store its value and check it when the value changed??? or is it possible to use delegates and events.

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Shaahinm wrote:

              the problem is that I am not able to find out whether user is increasing the value or decreasing it

              did I need that information in the two rules: if fraction==0.60 add +0.40 if fraction==0.85 add -0.40 ??? :)

              Luc Pattyn

              :badger: :jig: :badger:

              Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

              :jig: :badger: :jig:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups