有什么方法去辨别字符串里面是不是数字啊?

guohongchen 2003-12-16 10:50:45
!!
...全文
49 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianjy 2003-12-17
  • 打赏
  • 举报
回复
Dim isNum As Boolean
isNum = False
Dim i As Integer
Dim s As String
s = "abcdefaaghi"
For i = 1 To 9
If InStr(1, s, i) > 0 Then
isNum = True
Exit For
End If
Next
Debug.Print isNum
boydgmx 2003-12-17
  • 打赏
  • 举报
回复
如果你想逐个判断字符串中的每个字符,则
isNum=True
for i=1 to len(str)
if isnumeric(mid(str,i,1)) then
isNum=True
else
isNum=False
exit sub
end if
next
debug.print isNum
jhzhou882 2003-12-17
  • 打赏
  • 举报
回复
Isnumeric
可以判断出是不是数.包括带"."的和科学记数法如 e10
FSoft 2003-12-16
  • 打赏
  • 举报
回复
可以使用Isnumeric函数还判断
dim a as string
a="123"
if isnumeric(a)=true then end

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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