程序代码:
Private Sub Command1_Click()
Dim i As Long
Dim j As String
Dim o As Long
Dim yn As Boolean
For i = 0 To Me.Controls.Count - 1 'me 代表当前窗口
If InStr(1, Me.Controls(i).Name, "Text") > 0 Then '此处是你的text 控件的前缀,判断是否含 前缀
j = Mid(Me.Controls(i).Name, 5) '取除去前缀的部分
If IsNumeric(j) Then '是否是数字
o = CLng(j)
If o >= 1 And o <= 16 Then '此处是你的 text 的最大编号及最小编号
If Me.Controls(i).Text = "" Then '判断是否为空,这里还少写了一个判断,就是判断控件类型的,你要自己加就在最上面一层加上去
yn = True
Exit For
End If
End If
End If
End If
Next i
If yn Then
MsgBox Me.Controls(i).Name & " 内容为空!", vbCritical
Else
MsgBox "Text1 到 Text16 的内容均不为空!", vbInformation
End If
End Sub