VB6 IDE cannot load MSCOMCTL.OCX after update KB 2687323

After hours of effort, system restore, register, unregister cycles and a night’s sleep I have managed to pinpoint the problem. It turns out that the project file contains the below line: Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX The version information “2.0” it seems was the reason of not loading. Changing it to “2.1” in notepad solved the problem: Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0; … Read more

How to wait for a shell process to finish before executing further code in VB6

The secret sauce needed to do this is the WaitForSingleObject function, which blocks execution of your application’s process until the specified process completes (or times out). It’s part of the Windows API, easily called from a VB 6 application after adding the appropriate declaration to your code. That declaration would look something like this: Private … Read more

How can I pretty-print XML source using VB6 and MSXML?

After months of research I’ve come up with this. Public Function PrettyPrintXML(XML As String) As String Dim Reader As New SAXXMLReader60 Dim Writer As New MXXMLWriter60 Writer.indent = True Writer.standalone = False Writer.omitXMLDeclaration = False Writer.encoding = “utf-8” Set Reader.contentHandler = Writer Set Reader.dtdHandler = Writer Set Reader.errorHandler = Writer Call Reader.putProperty(“http://xml.org/sax/properties/declaration-handler”, _ Writer) Call … Read more

Implementing String.Format() in VB6

I couldn’t find one anywhere, so I made my own: Public PADDING_CHAR As String Public Function StringFormat(format_string As String, ParamArray values()) As String ‘VB6 implementation of .net String.Format(), slightly customized. ‘Tested with Office 2010 VBA (x64) Dim return_value As String Dim values_count As Integer ‘some error-handling constants: Const ERR_FORMAT_EXCEPTION As Long = vbObjectError Or 9001 … Read more

Break in Class Module vs. Break on Unhandled Errors (VB6 Error Trapping, Options Setting in IDE)

I’ll start with the first option. Break on all errors simply disables your error handlers. This is useful when you are attempting to debug after you’ve put in error handlers, because you can have errors in the handlers themselves, or you can lose track of where the error happened when the error bubbles up the … Read more