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. Limit parameter acceptable values

Limit parameter acceptable values

Scheduled Pinned Locked Moved Visual Basic
designtutorialquestion
3 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.
  • J Offline
    J Offline
    jcrussell
    wrote on last edited by
    #1

    Hello all I want to create a sub that takes an integer as a parameter like so: public sub foo(inNumber as integer) ... end sub what I want is, at design time, to limit the range of inNumber. for example, if the acceptable range is [2..5] then foo(1) would not compile but foo(3) would compile correctly How would I go about doing this? /jason

    S S 2 Replies Last reply
    0
    • J jcrussell

      Hello all I want to create a sub that takes an integer as a parameter like so: public sub foo(inNumber as integer) ... end sub what I want is, at design time, to limit the range of inNumber. for example, if the acceptable range is [2..5] then foo(1) would not compile but foo(3) would compile correctly How would I go about doing this? /jason

      S Offline
      S Offline
      S Douglas
      wrote on last edited by
      #2

      There isnt a way to do that. Use a select case statement inside your sub.


      ZeePain! wrote:

      This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

      thedailywtf.com[^]

      1 Reply Last reply
      0
      • J jcrussell

        Hello all I want to create a sub that takes an integer as a parameter like so: public sub foo(inNumber as integer) ... end sub what I want is, at design time, to limit the range of inNumber. for example, if the acceptable range is [2..5] then foo(1) would not compile but foo(3) would compile correctly How would I go about doing this? /jason

        S Offline
        S Offline
        Steve Pullan
        wrote on last edited by
        #3

        You're trying to limit a runtime value at design time. This can only be done by the designer including code to validate the parameters at runtime. AFAIK the standard tools and addon third party tools don't do this. You'll need to add the code to your functions manually and trap any errors. ...Steve

        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