I just read the above statement somewhere...
Why is IIf so... bad?
Printable View
I just read the above statement somewhere...
Why is IIf so... bad?
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?
Hi,
You can check this thread out for the debate:
http://www.vbforums.com/showthread.p...&highlight=iif
Have a good one!
BK
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.
Alright haha
Yeah, I even proved that If...ElseIf statements are faster than Select Case. :)
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. :thumb:
DoEvents bogs down a loops speed tremendously. They should have optimized this when Microsoft made VB.
I agree ... in general ... :)Quote:
Originally Posted by Jacob Roman
... which is ... ???Quote:
Originally Posted by Jacob Roman
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
Indeed, indeed ... I was just playng plain stupid so some people would benefit ... Thanks for your reply! :thumb:Quote:
Originally Posted by Jacob Roman
Anytime ;)
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