有关老是报错的问题?今天晚10点结分!
vbcb 2003-04-08 07:29:48 不知道为什么,我的程序老是报错,下面是代码:请帮忙分析
Private Function DataCheck(ByRef lngIndex As Long) As Long
On Error GoTo ErrLog
lngIndex = -1
DataCheck = 0
'如果该字段为非必填字段,请在判断该字段textbox文本为非空后再执行数据合法性检验
'姓名
If Len(txtFields(1).Text) > 50 Then '检查长度是否超出
DataCheck = 4
lngIndex = 1
Exit Function
End If
If Len(txtFields(1).Text) = 0 Then '检查非空字段是否为空
DataCheck = 5
lngIndex = 1
Exit Function
End If
'家庭人数
If IsNumeric(txtFields(2).Text) = False Then '检查是否数字
DataCheck = 2
lngIndex = 2
Exit Function
End If
If Len(txtFields(2).Text) = 0 Then '检查非空字段是否为空
DataCheck = 5
lngIndex = 2
Exit Function
End If
'联系地址
If Len(txtFields(3).Text) > 50 Then '检查长度是否超出
DataCheck = 4
lngIndex = 3
Exit Function
End If
If Len(txtFields(3).Text) = 0 Then '检查非空字段是否为空
DataCheck = 5
lngIndex = 3
Exit Function
End If
'联系电话
If IsNumeric(txtFields(4).Text) = False Then '检查是否数字
DataCheck = 2
lngIndex = 4
Exit Function
End If
If Len(txtFields(4).Text) > 10 Then '检查长度是否超出
DataCheck = 4
lngIndex = 4
Exit Function
End If
If Len(txtFields(4).Text) = 0 Then '检查非空字段是否为空
DataCheck = 5
lngIndex = 4
Exit Function
End If
'备注
If Len(txtFields(4).Text) > 50 Then '检查长度是否超出
DataCheck = 4
lngIndex = 4
Exit Function
End If
ErrLog:
DataCheck = 1
'WriteErrLogFile Me.Caption & ":DataCheck,", "错误号:" & Err.Number & ";错误源:" & Err.Source & ";错误描述:" & Err.Description
MsgBox "发现错误!错误号:" & Err.Number & ";错误源:" & Err.Source & ";错误描述:" & Err.Description & "。如果还有问题,请联系管理员解决。", vbCritical
End Function