过程声明与具有相同名称的事件或过程的描述不匹配 [英] procedure declaration does not match description of event or procedure having the same name
问题描述
我只是新手,我试图在Visual Basic 6中制作一个简单的程序。代码几乎等同于教科书。这是一种绘画程序。令人惊讶的是,它不能用这个问题的标题中给出的错误来编译。
这是代码:
I am just novice and I tried to make a simple program in Visual Basic 6. The code is almost equivalent to that in the textbook. It was meant to be a kind of a paint program. Surprisingly, it couldn't be compiled 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)
出现错误:
过程声明与事件或过程的描述不匹配
具有相同的名称
procedure declaration does not match description of event or procedure having the same name
推荐答案
问题出在这里:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
好的,因为你在VB6编程,你可以学习一些VB6手册中的技巧。暂时将方法重命名为其他类似qqToolbar_ButtonClick的方法,然后转到设计器,然后单击工具栏中的按钮,以在代码中重新生成事件。
Ok, since you are coding in VB6, you get to learn some of the tricks in the VB6 playbook. Temporarily rename the method to something else like qqToolbar_ButtonClick, then go to the designer and click the button in the toolbar to regenerate the event in the code.
如果签名已被错误地输入,它将从设计师正确地重新生成,您可能会看到问题。
In the event that the signature has been mistyped, it will regenerate from the designer correctly and you might see the issue.
另一个检查是查看ToolBar1是否被添加到控件数组?在这种情况下,方法签名需要如下所示:
Another check is to see if the ToolBar1 was added to a control array? In that case, the method signature needs to look like this:
Private Sub Toolbar1_ButtonClick(ByVal Index as Integer, ByVal Button As MSComctlLib.Button)
我希望其中一个帮助您解决问题。
I hope one of these helps solve the issue for you.
这篇关于过程声明与具有相同名称的事件或过程的描述不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!