Visual Basic 6.0 Error: ‘Compile Error: Procedure declaration does not match description of event or procedure having the same name’

System Requirements:

  • Visual Basic 6.0

The Problem:

After copying a control placed on a form in the VB 6.0 IDE you receive the following error message when you attempt to run the program.

Compile error:

Procedure declaration does not match description of event of procedure having the same name

Compile Error Message

The program will not compile correctly even after the VB control that you copied has been deleted from the form.

More Info

This seems to be a bug in the VB 6.0 IDE. Remember this?

Create Control Array Message

It asked you if you wanted to place the control into an array so that multiple controls named ‘Command1’ in this case could be referenced from a common name i.e. Command1(0), Command1(1), Command1(2) etc.

Very occasionally the VB IDE gets this wrong, attempting to reference a control variable as an array variable. This in turn leads to non-compliable code and no clear way to get out of the problem.

The Fix

The fix is to prevent the VB IDE from trying to treat the original variable as an array by removing its index parameter.

  1. Delete or rename the duplicate named control
  2. Note the name of the control in the error message
  3. Save your project and exit VB
  4. Open the location of your .vpb (Visual Basic Project) file
  5. Locate the .frm file (form) that your control appears in amongst the list of files
  6. Open notepad and drag and drop the .frm file into its window so that you can see the underlying code-behind the form
  7. Search the file for the name of the control named in the error message
  8. Beneath it you should find a parameter list associated with the control. Locate and delete the line “Index” line as highlighted below
  9. Save and exit notepad and restart the IDE

Or, if the control exposes it, clear the value of ‘index’ on the properties explorer in the IDE.

The Fix in Notepad