|
本帖最后由 xuwenning 于 2010-8-17 09:06 编辑
下面检查是文本数据是否正确
文本数据——必须是以0开头的最长为(0.0000)小数,或数据值为“-”号—表示没有
求代码优化统一使用一个模块来检查数据
还有一个条件是数据最长为(0.0000)小数点后四位的长度不知如何写了,请高手一并搞定
Private Sub txt1_AfterUpdate()
If Left(Me. txt1, 1) <> "0" Or Left(Me. txt1, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me. txt1 = ""
Me. txt1.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt2_AfterUpdate()
If Left(Me.Txt2, 1) <> "0" Or Left(Me.Txt2, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt2 = ""
Me.Txt2.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt3_AfterUpdate()
If Left(Me.Txt3, 1) <> "0" Or Left(Me.Txt3, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt3 = ""
Me.Txt3.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt4_AfterUpdate()
If Left(Me.Txt4, 1) <> "0" Or Left(Me.Txt4, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt4 = ""
Me.Txt4.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt5_AfterUpdate()
If Left(Me.Txt5, 1) <> "0" Or Left(Me.Txt5, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt5 = ""
Me.Txt5.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt6_AfterUpdate()
If Left(Me.Txt6, 1) <> "0" Or Left(Me.Txt6, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt6 = ""
Me.Txt6.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt7_AfterUpdate()
If Left(Me.Txt7, 1) <> "0" Or Left(Me.Txt7, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt7 = ""
Me.Txt7.SetFocus
Exit Sub
End If
End Sub
Private Sub Txt8_AfterUpdate()
If Left(Me.Txt8, 1) <> "0" Or Left(Me.Txt8, 1) <> "-" Then
MsgBox "无效数字首位必须是0"
Me.Txt8 = ""
Me.Txt8.SetFocus
Exit Sub
End If
End Sub |
|