Bugs in VbClassic (VisualBasic versions up to 6, but not including VisualBasicDotNet):
[[BadImplementsRefInCompatLib?]] / [[BadImplementsReflnCompatLib?]] Error Message:
A VisualBasic 6.0 compiler bug:
Workaround: In the project(s) getting the "[[BadImplementsRefInCompatLib?]]" error, drop from binary to project compatibility, recompile, and then go back to binary compatibility. (Then you have to recompile all projects that use them.)
What MicroSoft's "Q190078" article fails to mention is that you can get this error even if you strictly adhere to binary compatibility rules: If you change an interface in a way that makes it incompatible, VisualBasic correctly drops old GUIDS and assigns a new GUID to the interface. This also triggers the "[[BadImplementsRefInCompatLib?]]" error message.
(Not to mention some MicroSoft help desk person who typed "Ref<lowercase-ell>n" instead of "Ref<uppercase-eye>n". ;-)
This VbClassic problem remains present, even in service pack 6.
Conditional compilation disabled method implementation check:
In VisualBasic 6.0 (SP4), conditional compilation of method implementations in a class disables VisualBasic's check that you implemented all the methods of the interface.
(Since all methods of VisualBasic interfaces are "pure virtual" in the C++ sense, you have to implement all of them to have a valid (IE: non-crashing) program.)
Example: Create a new project, a "Standard EXE."
Add a class. Call it "I1". Put this in it:
Option Explicit Public Sub a() End Sub Public Sub b() End SubAdd another class. Leave it called "Class1". Put this in it:
Option Explicit Implements I1 Public Sub I1_a() Debug.Print "Now in I1_a()." End Sub #If 0 Then Public Sub I1_b() Debug.Print "Now in I1_b()." End Sub #End IfVisualBasic gave you a form. Give it a Form_Load event:
Option Explicit Private Sub Form_Load() Dim i As I1 Set i = New Class1 Call i.a Call i.b ' This call crashes VisualBasic Unload Me End SubRun it. VisualBasic and the IDE will crash on "Call i.b", because there is no code behind that method.
I get...
vb6.exe - Application Error (X) The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read". Click OK to terminate the program Click CANCEL to debug the program [OK] [Cancel](This bug caused me trouble in EnhancingVbUnit. -- JeffGrigg)
Public Form variables break binary compatibility:
In any VisualBasic ActiveX project,
Example:
'mForm' in the 'Class1' class module has arguments and/or a return type that is incompatible with a similar declaration in the version-compatible component. Original definition: Public mForm As Object Current definition: Public mForm As Form 'mForm' in the 'Class1' class module has arguments and/or a return type that is incompatible with a similar declaration in the version-compatible component. Original definition: Property Set mForm(ByVal RHS As Object) Current definition: Public mForm As Form Your application is incompatible with C:\...\Project1.dll. The project name and the .EXE filename for both applications are the same. Change the Project Name setting in the Project Options dialog box and use a unique name for the current .EXE file. You can see the specific incompatibilities by returning to design mode and running the project.
Line Continuation and Date Constants Don't Mix:
A VisualBasic 6.0 IDE bug: Date constants and line continuation don't mix.
Type this into the IDE:
Const dt As Date = _ #1/1/2001#it automatically changes your code to this:
Const dt As Date = # _ 1/1/2001#DING! Syntax error. Try to fix it, and VB breaks it again.
Workarounds:
Const dt As Date _ = #1/1/2001#or
Const dt As Date = _ CDate(#1/1/2001#)or
Const dt As Date = _ 0 + #1/1/2001#
This is actually a common class of bug in code formatters, to change the formatting such that it breaks some obscure or inconsistent rule in the syntax of the language. It's especially common (although not necessarily a bug any more) with formatters which are very configurable + lint-like things. --WilliamUnderwood
Other VbClassic Bugs: