Results 1 to 5 of 5

Thread: Iif ??????????????????????

  1. #1

    Thread Starter
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    I used the iif statement in my code on a post and someone told me that it is much slower than a regular if...then statement what makes it slower it seems like it should be faster because it only has to read one line of code. Any comments are welcome............unless i don't like them

  2. #2
    Guest
    it is slower, because it is a function. It goes something like this:

    iif:
    1: evaulate boolean expression(param 1)
    2: Do a regular if then else statement inside the function(determines whic parameter to return)
    3: assign correct return value, and return
    4: assign return value to variable.

    Also, since the return code, and the 2 possible values can be any type, they have to be variants(something like 22 bytes or mem, plus the actual type)

    the code looks something like:
    Code:
    Private Function iif(expr as Boolean, Opt1 as Variant, Opt2 as Variant) as Varient
        If expr Then
            iif = Opt1
        Else
            iif = Opt2
        End If
    End Function
    this is compared to just a regular if..then..else statement. Im sure you can see the difference.

    Z.

  3. #3

    Thread Starter
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    but like megatron said about the select case vs. if..then the differance is so minimal on today's computers it it not even worth mentioning. plus the reason it was writen was so that you can shorten the program by using what the computer already knows (i.e. windows API)

    Thanks

    Regards

    E.P.

  4. #4
    Guest
    Select case is just a nicely formatted if.. then.. elseif......
    end if statement there isnt any difference between the two, except code form.

  5. #5

    Thread Starter
    Fanatic Member ExtremePimpness's Avatar
    Join Date
    Jan 2001
    Location
    Indianapolis, Indana - USA
    Posts
    550
    that is true for the IIf statement also. What is the time differance does any one know( i doubt it is anything over a 1 or 2 miliseconds on a athlon 900 Mhz w/ 327MB RAM

Posting Permissions

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



Click Here to Expand Forum to Full Width