我只是新手,我试图在Visual Basic 6中创建一个简单的程序.代码几乎相当于教科书中的代码.它本来是一种油漆程序.令人惊讶的是,它无法使用此问题标题中给出的错误进行编译.
这是代码:
这是代码:
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
应用程序崩溃在以下行:
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之类的其他内容,然后转到设计器并单击工具栏中的按钮以在代码中重新生成事件.
另一项检查是查看ToolBar1是否已添加到控件数组中?在这种情况下,方法签名需要如下所示:
Private Sub Toolbar1_ButtonClick(ByVal Index as Integer,ByVal Button As MSComctlLib.Button)
我希望其中一个有助于解决问题.