设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

Access中判断内容是否为空的函数

1970-1-1 08:00| 发布者: tmtony『文章』| 查看: 3236| 评论: 0

在Access中没有IsNothing函数,只有Is Nothing这样的判断。
有时需要判断一下文本框的内容是否没有内容(或有错误)呢。可使用下面的函数


'===============================================================================-----Office中国--->>>>>>>>
'-函数名称:         gt_IsNothing
'-功能描述:         判断是否为空
'-输入参数:         参数1:rstr Variant 传递的内容
'-返回参数:         无
'-使用示例:         gt_IsNothing txtName.value
'-相关调用:         无
'-使用注意:         不适用除零或字段来源错误等情况
'-兼 容 性:         97,2000,XP,2003 compatible
'-参考资料:
'-作    者:         王宇虹  修改:王宇虹
'-创建日期;         2002-08-26  更新日期: 2002-08-28 ,2003-11-15
'-图    解:
'===============================================================================--<>>>>>
Public Function gt_IsNothing(rstr As Variant) As Boolean

Select Case VarType(rstr)
 '如果为空白
 Case vbEmpty
   gt_IsNothing = True
 '如果为空
 Case vbNull
   gt_IsNothing = True
 '如果是字符串但长度为0
 Case vbString
  If Len(rstr) = 0 Then gt_IsNothing = True
 '如果出错
 Case vbError
  gt_IsNothing = True
 '其它
 Case Else
  gt_IsNothing = True

End Select

End Function

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-7 01:11 , Processed in 0.068135 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部