3 ms·
DoEvents is a great tool if your project is small and you use it consciously. Just make sure it won't invoke any I/O or heavy logic. This is easy when your app
by qwerty456127 5y ago
DoEvents is a great tool if your project is small and you use it consciously. Just make sure it won't invoke any I/O or heavy logic. This is easy when your app is small. And DoEvents let's you KISS and short. Not a single time in my life it caused a problem because I would always switch to BackgroundWorkers as soon as the app would grow more complex.
On Error Resume Next wasn't anything really terrible either. You just enable it before a risky call so your program won't crash, do the call, disable it and validate the result of the call before using it. This way you just don't have to clutter your code with endless try-catch-finally clauses.
- codebolt 5y agoI always thought the classic synchronous message loop in Win32 was actually rather elegant if you took the time to understand the mechanics surrounding it. DoEvents is a bit crude but it serves a purpose in the context of VB6. Cant disagree about the error handling though, thats the absolute worst part of the language.
- tyingq 5y ago>DoEvents is a great tool if your project is small and you use it consciously. It exists in tcl/tk as "update" and/or "update idletasks".
- geon 5y ago> You just enable it before a risky call so your program won't crash, do the call, disable it and validate the result of the call before using it. This way you just don't have to clutter your code with endless try-catch-finally clauses. How is that in any way better than try/catch? It would be just as mush code, but without the syntax ensuring you disable it.
- qwerty456127 5y agoPerhaps you are right. But at least it's less nesting and I'm not sure special syntax to ensure you disable it is necessary - finding all occurrences of "On Error Resume Next" and matching "On Error Resume 0" statements is trivial. Both ways feel tidy than the other in their own way.
- feoren 5y agoI'm guessing you haven't seen a try/catch block in VB6 / VBA. It's not like a C code block; it's just another goto statement. What GP describes is much better because it's localized: control flow follows line after line. Try/catch blocks in VB6 scramble your control flow. And you still have lots of things you need to remember to do with that approach.
- ampdepolymerase 5y agoWhat is the difference between DoEvent and yield in modern async languages?