验证非浮点整数值 [英] validating a non float integer value

查看:81
本文介绍了验证非浮点整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:


函数isInt(输入)

isInt = true

for i = 1到len(输入)

d =中(输入,i,1)

如果Asc(d)< 48或Asc(d)> 57然后

isInt = false

退出

结束如果

next


结束功能

我尝试更换:


功能isInt(输入)


设置re =新的RegExp

re.Pattern =" [0-9]"

isInt = re.test(输入)


结束功能


但似乎没有用。


如何解决问题?


非常感谢您的帮助。


问候


Eugene Anthony

***发送来自开发人员指南 http://www.developersdex.com ***

解决方案

更正:


函数isInt(输入)

dim re,match

set re = new RegExp

re.Pattern =" \D"

re.Global = True

set match = re.Execute(输入)

如果match.count> 0然后

isInt = false

else

isInt = true

结束如果

set match = nothing

set re = nothing

结束功能


-

罗兰大厅

/ *这些信息的分发是希望它有用,但

没有任何保证;甚至没有适销性的暗示保证

或特定用途的适用性。 * /

Technet脚本中心 - http:// www .microsoft.com / technet / scriptcenter /

WSH 5.6文档 - http://msdn.microsoft.com/downloads/list/webdev.asp

MSDN Library - http://msdn.microsoft.com/library/default.asp


" Eugene Anthony"在消息中写道

news:eK ************** @ tk2msftngp13.phx.gbl ...

:function isInt(输入)

:isInt = true

:for i = 1 to len(输入)

:d = Mid(输入,i,1)

:如果Asc(d)< 48或Asc(d)> 57然后

:isInt = false

:退出

:结束如果

:next

:结束功能



:我尝试更换:



:function isInt (输入)

:设置re = new RegExp

:re.Pattern =" [0-9]"

:isInt = re.test(输入)

:结束功能


功能isInt(输入)

dim re,匹配

set re = new RegExp

re.Pattern =" \D"

re.Global = True

set match = re.Execute(输入)

如果match.count> 0然后

isInt = false

else

isInt = true

结束如果

set re = nothing

结束功能


-

Roland Hall

/ *这个信息的分发是希望它有用,但

没有任何保证;甚至没有适销性的暗示保证

或特定用途的适用性。 * /

Technet脚本中心 - http:// www .microsoft.com / technet / scriptcenter /

WSH 5.6文档 - http://msdn.microsoft.com/downloads/list/webdev.asp

MSDN Library - http://msdn.microsoft.com/library/default.asp


Eugene Anthony写道:

我试过替换为:

函数isInt(输入)

设置re = new RegExp
re.Pattern =" [0-9]"
isInt = re.test(输入)

结束功能

但似乎没有工作。

如何解决问题?。




单程:


函数IsInt(str)

IsInt = CDbl(str)= Int(str)

结束功能

-

戴夫安德森


未经请求的商业电子邮件将以


The code bellow:

function isInt(input)

isInt = true
for i=1 to len(input)
d = Mid(input,i,1)
if Asc(d) < 48 OR Asc(d) > 57 then
isInt = false
exit for
end if
next

end function
I tried replacing with:

function isInt(input)

Set re = new RegExp
re.Pattern = "[0-9]"
isInt = re.test(input)

end function

But dont seem to work.

How do I solve the problem?.

Your help is kindly appreciated.

Regards

Eugene Anthony
*** Sent via Developersdex http://www.developersdex.com ***

解决方案

Correction:

function isInt(input)
dim re, match
set re = new RegExp
re.Pattern = "\D"
re.Global = True
set match = re.Execute(input)
if match.count > 0 then
isInt = false
else
isInt = true
end if
set match = nothing
set re = nothing
end function

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


"Eugene Anthony" wrote in message
news:eK**************@tk2msftngp13.phx.gbl...
: function isInt(input)
: isInt = true
: for i=1 to len(input)
: d = Mid(input,i,1)
: if Asc(d) < 48 OR Asc(d) > 57 then
: isInt = false
: exit for
: end if
: next
: end function
:
: I tried replacing with:
:
: function isInt(input)
: Set re = new RegExp
: re.Pattern = "[0-9]"
: isInt = re.test(input)
: end function

function isInt(input)
dim re, match
set re = new RegExp
re.Pattern = "\D"
re.Global = True
set match = re.Execute(input)
if match.count > 0 then
isInt = false
else
isInt = true
end if
set re = nothing
end function

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Eugene Anthony wrote:

I tried replacing with:

function isInt(input)

Set re = new RegExp
re.Pattern = "[0-9]"
isInt = re.test(input)

end function

But dont seem to work.

How do I solve the problem?.



One way:

Function IsInt(str)
IsInt = CDbl(str) = Int(str)
End Function
--
Dave Anderson

Unsolicited commercial email will be read at a cost of


这篇关于验证非浮点整数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆