I\'m trying to run a legacy VB6 application on my desktop (it doesn\'t have a user interface, being a command-line app), and when I do, I get a message box saying
I have VB6 SP6 and I can reproduce this behavior. In a fresh project, put this code into a form. The project runs normally with F5. Right click the project and select Publish then Build Outputs. This generates the error message.
Option Explicit
Public Sub Init()
Dim blnErrorHandling As Boolean
If False Then
blnErrorHandling = True
Else
blnErrorHandling = False
End Sub
Now comment out the last four lines:
Option Explicit
Public Sub Init()
Dim blnErrorHandling As Boolean
' If False Then
' blnErrorHandling = True
' Else
' blnErrorHandling = False
End Sub
You no longer get the error and the outputs are built normally. I was quickly adding in some error handling to locate the source of a crash and If False Then
is perfectly valid. The MDAC checker said all was ok and a reboot didn't solve the problem.
For a VB6 program which is run as a command line application there is an extra stage required after compilation: the VB6 linker needs to be run on the executable to set it as a console program:
<VB6 dir>\LINK.EXE /EDIT /SUBSYSTEM:CONSOLE <program>.exe
Failure to do this will give the Method '~' of object '~' failed
error when the program is run.