what is the better way to handle errors in VB6

First of all, go get MZTools for Visual Basic 6, its free and invaluable. Second add a custom error handler on every function (yes, every function). The error handler we use looks something like this: On Error GoTo {PROCEDURE_NAME}_Error {PROCEDURE_BODY} On Error GoTo 0 Exit {PROCEDURE_TYPE} {PROCEDURE_NAME}_Error: LogError “Error ” & Err.Number & ” (” … Read more

Self Inspection of VB6 UDTs

Contrary to what others have said, it IS possible to get run-time type information for UDT’s in VB6 (although it is not a built-in language feature). Microsoft’s TypeLib Information Object Library (tlbinf32.dll) allows you to programmatically inspect COM type information at run-time. You should already have this component if you have Visual Studio installed: to … Read more

Recordset .value property

Value is the default property of the Field object, so in VB6 there is no difference between rs(“bookingdate”) and rs(“bookingdate”).value when used without Set. I personally prefer not using default properties that don’t take parameters. It makes the code less confusing IMO. In VB.NET the default property must have a parameter, so this situation does … 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