[求助]判断类型为“2004.06.23”格式的函数

wylf 2005-06-20 07:32:43
以下是我写的判断类型如“2004.06.23”格式的函数
dim bs
bs=0
function check(str)
str=trim(str)
if len(str)<>10 then
bs=1
else
for i=1 to 10
a= asc(mid(str,i,1))
if i<>5 and i<>8 then
if a>47 and a<58 then
else
bs=1
end if
else
end if
next
end if
end function
但是运行时显示
错误类型:
Microsoft VBScript 运行时错误 (0x800A005E)
无效使用 Null: 'mid(...)'
请帮忙找找错误 ,急!
...全文
111 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zol9993 2005-06-20
  • 打赏
  • 举报
回复
我买了一个 便宜的 asp.net空间!才50元!高兴!给分!!
100mb 的!可以做论坛!才 50元!!速度飞快!
www.hi876.com 你们看看
tuyah 2005-06-20
  • 打赏
  • 举报
回复
Function CheckDate(str)
Dim regEx, Match, Matches, flag

Set regEx = New RegExp
regEx.Pattern = "\d{4}\.\d{2}\.\d{2}"
regEx.IgnoreCase = True
regEx.Global = True

Set Matches = regEx.Execute(str)
For Each Match in Matches
RetStr = RetStr & Match.FirstIndex
RetStr = RetStr & Match.Value
Next

if RetStr="" then
CheckDate = 0
else
CheckDate = 1
end if
End Function
QQgenie 2005-06-20
  • 打赏
  • 举报
回复
dim bs
bs=0
function check(str)
str=trim(str)
if len(str)<>10 or instr(str,".")=0 then
bs=1
else
if isdate(str) then
else
bs=1
end if
end if
check=bs
end function
up1002 2005-06-20
  • 打赏
  • 举报
回复
没必要这样写呀。VBS有专门的判断是否日期的函数 isDate()。
看你的函数当中也没有判断年/月/日的分隔符号是否为".",
如果要判断str是否为合法的日期,并且年/月/日的分隔符号为".",完全可以

if isDate(str) and InStr(InStr(str,".")+1,str,".")>0

基本上不会有问题。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧