时 间:2009-09-10 21:18:53
作 者:江羽 ID:3967 城市:南昌
摘 要:判断空值或空字符串五种方法的比较与探讨
正 文:
1、假定是定义了一个空字符串,那一、二、五方法有效
Dim strN As String
strN = ""
If Trim(strN) = vbNullString Then
MsgBox "判断空值方法(一)"
End If
If Len(strN) = 0 Then
MsgBox "判断空值方法(二)"
End If
If IsNull(strN) Then
MsgBox "判断空值方法(三)"
End If
If strN = Null Then
MsgBox "判断空值方法(四)"
End If
If strN = "" Then
MsgBox "判断空值方法(五)"
End If
2、如果判断文本控件是否输入字符,则方法三有效
If Trim(Me.Text1) = vbNullString Then
MsgBox "判断空值方法(一)"
End If
If Len(Me.Text1) = 0 Then
MsgBox "判断空值方法(二)"
End If
If IsNull(Me.Text1) Then
MsgBox "判断空值方法(三)"
End If
If Me.Text1 = Null Then
MsgBox "判断空值方法(四)"
End If
If Me.Text1 = "" Then
MsgBox "判断空值方法(五)"
End If
如果感兴趣可以自己实际测试一下
Access软件网QQ交流群 (群号:483923997)
Access源码网店
|