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. Other Discussions
  3. The Weird and The Wonderful
  4. CBool(IIf(BooleanFunction(), True, False))

CBool(IIf(BooleanFunction(), True, False))

Scheduled Pinned Locked Moved The Weird and The Wonderful
2 Posts 2 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.
  • G Offline
    G Offline
    Gregory Gadow
    wrote on last edited by
    #1

    We had a contract programmer do some work for us recently. Alas, he was hired by the Pointy Haired One, so this month I get to go over his work and correct errors. Among the steaming pile, I found this nugget:

    RunTSMenuItem.Enabled = CBool(IIf(MyUser.HasPermission(Permission.Admin), True, False))

    When a user logs into the application, an instance of MyUser is created with all of the user's permissions (among other data.) HasPermission(Permission.whatever) will return true if the user has the requested permission and false otherwise. The above code activates a menu item on a form if the user is an administrator, otherwise the menu item is inactive. Unfortunately, this guy was overly fond of IIf and used it every opportunity he could, whether needed or not.

    W 1 Reply Last reply
    0
    • G Gregory Gadow

      We had a contract programmer do some work for us recently. Alas, he was hired by the Pointy Haired One, so this month I get to go over his work and correct errors. Among the steaming pile, I found this nugget:

      RunTSMenuItem.Enabled = CBool(IIf(MyUser.HasPermission(Permission.Admin), True, False))

      When a user logs into the application, an instance of MyUser is created with all of the user's permissions (among other data.) HasPermission(Permission.whatever) will return true if the user has the requested permission and false otherwise. The above code activates a menu item on a form if the user is an administrator, otherwise the menu item is inactive. Unfortunately, this guy was overly fond of IIf and used it every opportunity he could, whether needed or not.

      W Offline
      W Offline
      Wes Jones
      wrote on last edited by
      #2

      That's a mighty nice turd you found there

      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