Dim ocontrol As Control For Each ocontrol In Me.Controls If LCase(TypeName(ocontrol)) = "textbox" Then If ocontrol.Name = "Text1" Then ocontrol.Text = "aaa" End If End If Next
如果你的textbox控件如你示例的那样都有序号的话:dim i aslong for i=1 to 5 me("tb" & i).text =i next
如果你的textbox控件名称,如你示例的那样都有序号的话:dim i as long for i=1 to 5 me("tb" & i).text =i next
Dim ocontrol As Control For Each ocontrol In Me.Controls If LCase(TypeName(ocontrol)) = "textbox" Then ' ocontrol.Text = ocontrol.Tag '需要在textbox的tag写上1 2 3 ocontrol.Text = Right(ocontrol.Name, Len(ocontrol.Name) - Len("Text")) '假设控件名是TextX类型 '最好还是用控件数组 End If Next
for i=1 to 5
text(i).text=i
next i
For Each ocontrol In Me.Controls
If LCase(TypeName(ocontrol)) = "textbox" Then
If ocontrol.Name = "Text1" Then
ocontrol.Text = "aaa"
End If
End If
Next
for i=1 to 5
me("tb" & i).text =i
next
for i=1 to 5
me("tb" & i).text =i
next
Dim ocontrol As Control
For Each ocontrol In Me.Controls
If LCase(TypeName(ocontrol)) = "textbox" Then
' ocontrol.Text = ocontrol.Tag '需要在textbox的tag写上1 2 3
ocontrol.Text = Right(ocontrol.Name, Len(ocontrol.Name) - Len("Text")) '假设控件名是TextX类型
'最好还是用控件数组
End If
Next
dim i as long
for i=1 to 5
Controls("tb" & i).text =i
next参考:
http://tieba.baidu.com/f?kz=1016288544