Results 1 to 12 of 12

Thread: [RESOLVED] IIf = worst function ever written?

  1. #1

    Thread Starter
    Hyperactive Member Frodo_Baggins's Avatar
    Join Date
    Feb 2004
    Location
    Sao Paulo, Brazil
    Posts
    397

    Resolved [RESOLVED] IIf = worst function ever written?

    I just read the above statement somewhere...
    Why is IIf so... bad?
    Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.

  2. #2
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: IIf = worst function ever written?

    Well, I havn't used it in VB, but I used its equivelant in JavaScript a lot. I like it. Maybe it uses a lot of resources? Though I doubt it. Maybe the person was just angry at the world?
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  3. #3
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: IIf = worst function ever written?

    Hi,

    You can check this thread out for the debate:

    http://www.vbforums.com/showthread.p...&highlight=iif

    Have a good one!
    BK

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member Frodo_Baggins's Avatar
    Join Date
    Feb 2004
    Location
    Sao Paulo, Brazil
    Posts
    397

    Re: IIf = worst function ever written?

    Alright haha
    Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] IIf = worst function ever written?

    Yeah, I even proved that If...ElseIf statements are faster than Select Case.

  7. #7
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] IIf = worst function ever written?

    Also, I believe that DoEvents is the worse function ever written, although it is needed to get events going. I prefer API's over DoEvents using the same code that C++ uses in loops.

    DoEvents bogs down a loops speed tremendously. They should have optimized this when Microsoft made VB.

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] IIf = worst function ever written?

    Quote Originally Posted by Jacob Roman
    Also, I believe that DoEvents is the worse function ever written, ... They should have optimized this when Microsoft made VB
    I agree ... in general ...

    Quote Originally Posted by Jacob Roman
    ... I prefer API's over DoEvents using the same code that C++ uses in loops. ...
    ... which is ... ???

  9. #9
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] IIf = worst function ever written?

    The PeekMessage, TranslateMessage, and DispatchMessage API's, used like so:

    VB Code:
    1. If PeekMessage(MSG, 0, 0, 0, PM_REMOVE) Then
    2.                    
    3.             If MSG.message = WM_QUIT Then Exit Function
    4.                    
    5.             TranslateMessage MSG
    6.             DispatchMessage MSG
    7.        
    8.         End If

    Of course your gonna need some constants and a User Defined Type called Message (MSG was declared Message).

    Here's some links with a description of them with a code example in the Classical link:

    TranslateMessage
    DispatchMessage
    PeekMessage

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] IIf = worst function ever written?

    Quote Originally Posted by Jacob Roman
    ... Of course your gonna need some constants and a User Defined Type called Message ...
    Indeed, indeed ... I was just playng plain stupid so some people would benefit ... Thanks for your reply!

  11. #11
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [RESOLVED] IIf = worst function ever written?

    Anytime

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] IIf = worst function ever written?

    You should use GetMessage rather than PeekMessage, otherwise your message can get dispatched twice.

    VB Code:
    1. Do While GetMessage(udtMsg, 0, 0, 0)
    2.     TranslateMessage udtMsg
    3.     DispatchMessage udtMsg
    4. Loop
    Last edited by penagate; Jul 9th, 2005 at 10:02 AM.

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