怎么用VB编写一个能查出1串字符中,各个英文字母的个数

来源:百度知道 编辑:UC知道 时间:2024/06/15 05:15:48

dim p(85 to 122) as long
dim yourstr as string
dim t as long
dim i as long
dim myresult as strin

yourstr='你的字符串
for i=1 to len(yourstr)
t=asc(mid(yourstr,i,1))
if t>=85 and t<=122 then p(t)=p(t)+1
next i
for i=85 to 90
if p(i)>0 thenmyresult=myresult +char(i)+":"+cstr(p(i))+"个"
next i
for i=97 to 122
if p(i)>0 then myresult=myresult +char(i)+":"+cstr(p(i))+"个"
next i
msgbox(myresult)
'这样行不!!

利用ASCⅡ码诶``````当字符ASCⅡ码在英文字母的范围内即值为TRUE时定义的变量加1```至于代码``找书翻翻就可以了```否则你VB就白学了```