下面这段小程序,编译时出现变量未定义怎么解决
Option ExplicitPrivate WithEvents NewButton As CommandButton
Private Sub NewButton_Click()
MsgBox ″您选中的是动态增加的按钮!″
End Sub
Private Sub Command1_Click()
If NewButton Is Nothing Then
NewButton.Move Command1.Left + Command1.Width + 240, Command1.Top
NewButton.Caption = ″新增的按钮″
NewButton.Visible = True
End If
Set NewButton = Controls.Add(″″, ″cmdNew″, Me)
End Sub
Private Sub Command2_Click()
If NewButton Is Nothing Then
Else
Controls.Remove NewButton
Set NewButton = Nothing
End If
End Sub