使用VBScript判断一个字符串全是字母的代码

技术流评论4,9321阅读模式

最近在研究一个小工具,用到这个功能,但是发现网上没有现成的代码,所以自己写了一个。此VBS代码用于判断一个输入的字符串的字符形式——全都是字母,或不全是字母。

Dim Yuanzifan  '欢迎访问原梓番博客
Dim LenOfString
Dim Arr(100)文章源自原紫番博客-https://www.yuanzifan.com/1340.html

Yuanzifan=InputBox("输入一个长度小于100的字符串")
LenOfString=Len(Yuanzifan)文章源自原紫番博客-https://www.yuanzifan.com/1340.html

For i=1 To LenOfString
Arr(i)=Mid(Yuanzifan,i,1)
Next文章源自原紫番博客-https://www.yuanzifan.com/1340.html

SType=0
For j=1 To LenOfString
If Asc(Arr(j))>96 And Asc(Arr(j))<123 Then
SType=SType+1
ElseIf Asc(Arr(j))>64 And Asc(Arr(j))<91 Then
SType=SType+1
End If
Next文章源自原紫番博客-https://www.yuanzifan.com/1340.html

If SType=LenOfString Then
MsgBox "全是字母:www.yuanzifan.com"
Else
MsgBox "不全是字母:www.yuanzifan.com"
End If文章源自原紫番博客-https://www.yuanzifan.com/1340.html 文章源自原紫番博客-https://www.yuanzifan.com/1340.html

 最后更新:2013-12-10

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证