Consulting

Results 1 to 3 of 3

Thread: Solved: display 100% maximum

  1. #1

    Solved: display 100% maximum

    [VBA]Dim v As String
    v = Replace(Me.MPct, "%", "")
    Me.MPct = Val(v) & "%"
    [/VBA]

    I have this code that allows the user to enter percent number. I would like to prevent the user from enter anything greater than 100%.

    i.e. if the user types 150% and exits from the textbox, display the amount as 100%. if the user enters 50% and exits from the textbox, then it displays 50%.

    thank you for your help

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Like this:
    [VBA] Dim v As String

    v = Replace(Me.MPct, "%", "")

    If Val(v) > 100 Then v = 100
    If Val(v) <= 0 Then v = 0

    Me.MPct = v & "%"
    [/VBA]

    Artik

  3. #3
    Works Great...Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •