dim ctr as Object For Each ctr in Form1.Controls If TypeName(ctl)="TextBox" Then '你的操作 End If Next
跟楼上的一样,小许不同
Dim Ctl As Control For Each Ctr In Me.Controls If UCase$(TypeName(Ctl)) = UCase$("TextBox") Then '操作 End If Next
2个问题:1.此代码应该写在哪里呢,我是为了对所有text监控? 2.在操作方面,我想进行焦点判断,使用ctr_Gotfocus好像不行啊? Dim Ctl As Control For Each Ctr In Me.Controls If UCase$(TypeName(Ctl)) = UCase$("TextBox") Then if ctr_gotfocus then ctr.backcolor="" end if End If Next 这段代码应该如何修改?
Private Sub Form_Click() Dim Ctl As Control For Each ctr In Me.Controls If Me.ActiveControl Is ctr Then ctr.BackColor = vbRed Next End Sub
For Each ctr in Form1.Controls
If TypeName(ctl)="TextBox" Then
'你的操作
End If
Next
跟楼上的一样,小许不同
Dim Ctl As Control
For Each Ctr In Me.Controls
If UCase$(TypeName(Ctl)) = UCase$("TextBox") Then
'操作
End If
Next
2.在操作方面,我想进行焦点判断,使用ctr_Gotfocus好像不行啊?
Dim Ctl As Control
For Each Ctr In Me.Controls
If UCase$(TypeName(Ctl)) = UCase$("TextBox") Then
if ctr_gotfocus then
ctr.backcolor=""
end if
End If
Next
这段代码应该如何修改?
Dim Ctl As Control
For Each ctr In Me.Controls
If Me.ActiveControl Is ctr Then ctr.BackColor = vbRed
Next
End Sub
当点击文本框时不会出现form_click事件,请高手再给答案