|
-
Jul 8th, 2005, 06:30 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Jul 8th, 2005, 06:36 PM
#2
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?
-
Jul 8th, 2005, 06:37 PM
#3
Addicted Member
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
-
Jul 8th, 2005, 07:02 PM
#4
Re: IIf = worst function ever written?
The reason IIF is bad/slow is that it always evaluates both sides of the equation even if the first part is found to be True.
-
Jul 8th, 2005, 07:04 PM
#5
Thread Starter
Hyperactive Member
Re: IIf = worst function ever written?
Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.
-
Jul 8th, 2005, 07:39 PM
#6
Re: [RESOLVED] IIf = worst function ever written?
Yeah, I even proved that If...ElseIf statements are faster than Select Case.
-
Jul 8th, 2005, 07:51 PM
#7
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.
-
Jul 8th, 2005, 07:56 PM
#8
Re: [RESOLVED] IIf = worst function ever written?
 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 ...
 Originally Posted by Jacob Roman
... I prefer API's over DoEvents using the same code that C++ uses in loops. ...
... which is ... ???
-
Jul 8th, 2005, 08:01 PM
#9
Re: [RESOLVED] IIf = worst function ever written?
The PeekMessage, TranslateMessage, and DispatchMessage API's, used like so:
VB Code:
If PeekMessage(MSG, 0, 0, 0, PM_REMOVE) Then
If MSG.message = WM_QUIT Then Exit Function
TranslateMessage MSG
DispatchMessage MSG
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
Last edited by Jacob Roman; Jul 8th, 2005 at 08:04 PM.
-
Jul 8th, 2005, 08:26 PM
#10
Re: [RESOLVED] IIf = worst function ever written?
 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!
-
Jul 8th, 2005, 08:30 PM
#11
Re: [RESOLVED] IIf = worst function ever written?
Anytime
-
Jul 9th, 2005, 09:58 AM
#12
Re: [RESOLVED] IIf = worst function ever written?
You should use GetMessage rather than PeekMessage, otherwise your message can get dispatched twice.
VB Code:
Do While GetMessage(udtMsg, 0, 0, 0)
TranslateMessage udtMsg
DispatchMessage udtMsg
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|