Sub ControlProcessor(MyControl As Control)
If TypeOf MyControl Is CommandButton Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is CheckBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is TextBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
End If
End Sub
If TypeOf MyControl Is CommandButton Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is CheckBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is TextBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
End If
End Sub
If TypeOf NewItem Is Line Then
MsgBox "Ok"
End If
判断不了
而
TypeName(NewItem)="Line"可以CommandButton用那种方法都可以了,这两种在使用上有什么不同么?
MsgBox "Ok"
End If
估计你的不能跟踪是因为你的控件对象是动态增加的吧,
如果那样,一定要给动态对象赋值的(就像NEW)。
Set ln1 = Controls.Add("vb.line", "ln1")
With ln1
.Visible = True
.X1 = 500
.X2 = 500
.Y1 = 500
.Y2 =500
End With
If TypeOf ln1 Is Line Then MsgBox ln1.Name
Dim ln1 As Line
Set ln1 = Controls.Add("vb.line", "ln1")
With ln1
.Visible = True
.X1 = 500
.X2 = 500
.Y1 = 500
.Y2 =500
End With
If TypeOf ln1 Is Line Then MsgBox ln1.Name
…… 随便写比如line123都是对的。
---------------------------------------------------------
Montaque==Digitalboy==Houyongfeng==Monkey