Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    A substitue for IIF(expr,Tue,False)?

    I would like to avoid using

    If expr Then
    Something
    Else
    Something Else
    End If

    I was sure there was something but I can't find a reference for it and nothing I tried is working.

    Thanks for your help.
    Scott Stewart
    Always happy to learn from pros.

  • #2
    New Coder
    Join Date
    Aug 2004
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "Select Case" maybe? (Not sure if you know about this one or this is what you're wanting.)

    http://www.devguru.com/Technologies/...electcase.html

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    You can use a normal If...Then...Else statement in a single line without EndIf.

    Visual Basic:
    CheckIt = IIf(TestMe > 1000, "Large", "Small")

    VBScript:
    If TestMe > 1000 Then CheckIt = "Large" Else CheckIt = "Small"

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks Glenn,
    I didn't know I could use an Else in the same line. I should have. Maybe just an old habit of putting it in a block. I ended up doing it the way I didn't want to just so I could move on. I can go back and change those lines now. The reason? It just looks cleaner.
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

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