用InputBox函数输入一个字符串,编写程序用MseeageBox函数输出这个字符串中的大写字母及其个数。

来源:百度知道 编辑:UC知道 时间:2024/06/22 02:10:12
如输入字符串为“aBcdEFgHij”,则输出为“BEFH”和 4。

这个不难啊,大写字母的Ascii和小写字母的Ascii值是不同的。。大写字母是65-90 我直接写了一个函数给你。。你直接调用好了。
function checkstring(mystring)
stringlength=len(mystring)
total=0
for i = 1 to stringlength
stringascii=Asc(Mid(mystring,i,1))
if stringascii>=65 and stringascii<=90 then
u=u&Mid(mystring,i,1)
total=total+1
end if
next
dim returns(2)
returns(0)=total
returns(1)=u
checkstring=returns
end function
'演示
response.write checkstring("mYstRing")(1)
把后括号的1改为0则是显示总数。

http://hi.baidu.com/tolyzhang