The procedure declaration does not match the description of the event or procedure with the same name

I'm just a beginner, and I tried to make a simple program in Visual Basic 6. The code is almost equivalent to that in the tutorial. It meant to be a kind of drawing program. Surprisingly, it was not possible to compile with the error given in the title of this question. This is the code:

Option Explicit Dim Col As Long Private Sub Form_Load() AutoRedraw = True BackColor = vbWhite Col = vbBlack DrawWidth = 3 End Sub Private Sub Command1_Click() CommonDialog1.ShowOpen Form1.Picture = LoadPicture(CommonDialog1.FileName) End Sub Private Sub Command2_Click() CommonDialog1.ShowSave SavePicture Image, CommonDialog1.FileName End Sub Private Sub Command3_Click() CommonDialog1.ShowColor Col = CommonDialog1.Color End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) PSet (X, Y), Col End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "Line1" DrawWidth = 3 Case "Line2" DrawWidth = 20 End Select End Sub 

The application crashes on the following line:

 Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) 

With an error:

The procedure declaration does not match the description of the event or procedure with the same name

+7
source share
1 answer

The problem is here:

 Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) 

Well, since you are coding in VB6, you will learn some of the tricks in the VB6 playbook. Rename the method temporarily to something else, for example qqToolbar_ButtonClick, then go to the designer and click the button on the toolbar to restore the event in the code.

If the signature was erroneous, it will be correctly restored from the constructor, and you can see this problem.

Another test is to see if ToolBar1 is added to the control array? In this case, the method signature should look like this:

 Private Sub Toolbar1_ButtonClick(ByVal Index as Integer, ByVal Button As MSComctlLib.Button) 

I hope one of them helps solve the problem for you.

+20
source

All Articles