请问 VB窗体中有TEXT1-5,想要得出有输入数据的TEXT的个数
请问VB窗体中有TEXT1-5,共5个TEXT,当在有些TEXT中输入数据时,想要得出有输入数据的TEXT的个数,然后在COMMAND1中显示出,当以上5个TEXT中有输...
请问 VB窗体中有TEXT1-5,共5个TEXT,当在有些TEXT中输入数据时,想要得出有输入数据的TEXT的个数,然后在COMMAND1中显示出,当以上5个TEXT中有输入数据的个数大于4的时候,显示“超过”,小于4的时候显示“未超过”。请高手帮忙写出代码,谢谢!
展开
1个回答
展开全部
Private Sub Command1_Click()
a = 0
If Text1.Text <> "" Then a = a + 1
If Text2.Text <> "" Then a = a + 1
If Text3.Text <> "" Then a = a + 1
If Text4.Text <> "" Then a = a + 1
If Text5.Text <> "" Then a = a + 1
If a > 4 Then '>4
MsgBox "超过"
Else '<=4
MsgBox "未超过"
End If
End Sub
a = 0
If Text1.Text <> "" Then a = a + 1
If Text2.Text <> "" Then a = a + 1
If Text3.Text <> "" Then a = a + 1
If Text4.Text <> "" Then a = a + 1
If Text5.Text <> "" Then a = a + 1
If a > 4 Then '>4
MsgBox "超过"
Else '<=4
MsgBox "未超过"
End If
End Sub
追问
我是想再COMMAND1上显示“超过”或者“未超过”,不是弹出MSGBOX,谢谢
追答
Private Sub Command1_Click()
a = 0
If Text1.Text "" Then a = a + 1
If Text2.Text "" Then a = a + 1
If Text3.Text "" Then a = a + 1
If Text4.Text "" Then a = a + 1
If Text5.Text "" Then a = a + 1
If a > 4 Then '>4
Command1.Caption = "超过"
Else '<=4
Command1.Caption = "未超过"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询