我用如下代码Dim i As Integer
Dim objControl As Control
For i = 0 To Me.Controls.Count - 1
Set objControl = Me.Controls(i)
If TypeOf objControl Is TextBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf objControl Is ComboBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf objControl Is CheckBox And objControl.Value <> Empty Then
flag = False
End If
Next i
汇报错“对想不支持该属性或方法”,我该怎么写
谢谢在线等
Dim objControl As Control
For i = 0 To Me.Controls.Count - 1
Set objControl = Me.Controls(i)
If TypeOf objControl Is TextBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf objControl Is ComboBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf objControl Is CheckBox And objControl.Value <> Empty Then
flag = False
End If
Next i
汇报错“对想不支持该属性或方法”,我该怎么写
谢谢在线等
解决方案 »
- 秩亏方程组求解
- 超级绿豆(MSMVP - VB)请进给您分谢谢
- 紧急求助!!!!!!!!!!!!!!!!!!!!!!!!!!
- 怎样在VB的Picture控件中显示保存在数据库中的二进制文件
- 我刚考试,我用的HB(不是2B)铅笔填得答案,机器能认出来吗?请大家告诉我~急!!
- 想问一下在VB中编写一个DLL文件,能否实现往固定IP,端口发送UDP包,怎样编?初初学,请各位多多指教!
- ActiveReports支持中文吗?
- vb6 如何读取photoshop 的psd文件
- 找开ACCESS数据库的问题,对于XP下的ACCESS数据库好像用ADO打不开
- 求助:利用VB代码,按照记录先后顺序统计数据
- datareport运行出现错误“无效数据源”?
- 打印的一个问题,请帮帮忙!
For each control in Me.Controls
If TypeOf vnt Is TextBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf vnt Is ComboBox And objControl.Text <> Empty Then
flag = False
End If
If TypeOf vnt Is CheckBox And objControl.Value <> Empty Then
flag = False
End If
Next i
' 像下面这样写没问题Option ExplicitPrivate Sub Command1_Click()
Dim i As Integer, flag As Boolean
Dim objControl As Control
For i = 0 To Me.Controls.Count - 1
Set objControl = Me.Controls(i)
If TypeOf objControl Is TextBox Then
If objControl.Text <> Empty Then flag = False
End If
If TypeOf objControl Is ComboBox Then
If objControl.Text <> Empty Then flag = False
End If
If TypeOf objControl Is CheckBox Then
If objControl.Text <> Empty Then flag = False
End If
Next i
End Sub
' 我觉得这样写更好一些Option ExplicitPrivate Sub Command1_Click()
Dim i As Integer, flag As Boolean
Dim objControl As Control
For i = 0 To Me.Controls.Count - 1
Set objControl = Me.Controls(i)
Select Case TypeName(objControl)
Case "TextBox", "ComboBox"
If objControl.Text <> Empty Then flag = False
Case "CheckBox"
If objControl.Value <> Empty Then flag = False
Case "other"
'......
End Select
Next i
End Sub