[求助]怎么遍历梦一类控件
比如我想遍历表单中所有的text控件,应该怎么做
Private Sub Command1_Click(Index As Integer)
Dim ctrl As Control
Dim i As Integer
i = 0
For Each ctrl In Controls
if type of ctrl is textbox then '说语法错误
If ctrl.Text = "" Then
i = i + 1
End If
End If
Next
If i = 4 Then
MsgBox ("你没有输入任何信息,不能添加空记录!")
Text1.SetFocus
Else
If MsgBox("是否添加新记录?", vbYesNo, "添加记录") = 6 Then
With Form1.Adodc1.Recordset
.AddNew
!姓名 = Text1.Text
!出生日期 = Text2.Text
!座机 = Text3.Text
!手机 = Text4.Text
.Update
End With
Form3.Hide
End If
End If
End Sub