奇怪的现象:使用CommonDialog控件后,用Msgbox居然要判断2次?----请大家试试看。
我试过不执行CommonDialog控件的showOpen方法,就正确。但只要执行过一次CommonDialog控件的showOpen方法后,以后都不正确,即msgbox要回答2次,程序部分原码如下:
Private Function CheckData() As Boolean
'检查数据的合法性
Dim rst As ADODB.Recordset
Dim msgt As String
CommonDialog1.Filter = "Microsoft Excel(*.xls)|*.xl*"
CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.ShowOpen
msgt = ""
If Len(Text1.Text) < 6 Then
msgt = "年月位数应为6位数,如200105!"
Else
If SubStr(Text1.Text, 5, 2) < "01" Or SubStr(Text1.Text, 5, 2) > "12" Then
msgt = " 月份应为01--12月!"
Else
If Text1.Text <= "199101" Or Text1.Text >= "204912" Then
msgt = " 年月超出范围199101--204912!"
End If
End If
End If
If Not msgt = "" Then
MsgBox (msgt) '本语句执行结果要显示2次
Text1.SetFocus
CheckData = False
Exit Function
End If
End Function
请高手指教,谢谢!