MyError has to be a Variant type: in VB6 For
-Each
enumeration has to be done using a Variant.
Use
Dim MyError As Variant
instead.
質問
I am running some legacy VB6 code on a 64bit Windows 7 machine and am running into some weird errors.
my code blows up here:
with the message:
a whole section of code above this error handling is precededed by:
On Error GoTo ErrorTrap
ErrorTrap being my For Each loops seen above.
What causes this type mismatch?
解決
MyError has to be a Variant type: in VB6 For
-Each
enumeration has to be done using a Variant.
Use
Dim MyError As Variant
instead.
他のヒント
If your code has anything to do with ADO then it could be the known VB6 ADO & Win 7 issue described here: http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/3a4ce946-effa-4f77-98a6-34f11c6b5a13. It seems that typelibs changed in Win7 Sp1 which could make VB6 apps compiled on prior platforms crash when run on Win 7 or apps compiled on Win 7 crash when run on prior platforms. The linked article provides some suggestions for solutions, the easiest of which if you have the source code is to switch to use late binding when viable.