| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 645 人关注过本帖
标题:[求助]dim srt as string()
只看楼主 加入收藏
lsdm
Rank: 1
等 级:新手上路
帖 子:140
专家分:0
注 册:2006-1-7
收藏
 问题点数:0 回复次数:5 
[求助]dim srt as string()
这是一个判断输入的字符串有大写字母多少个,小写字母多少个,数字字符多少个,其它字符多少个的代码,是我看的教材上的,我不太明白,请那位大虾给逐句注释一下,不胜感谢!

dim a(4) as integer,ch as srting,instring as integer
dim i as integer
dim srt as string()={"大写字母","小写字母","数字字符","其它字符"}
instring=txtinput.text
for i=0 to instring.length-1
ch=instring.chars(i)
select case ch
case "A"to"Z"
a(0)=a(0)+1
case "a"to"z"
a(1)=a(1)+1
case "0"to"9"
a(2)=a(2)+1
case else
a(3)=a(3)+1
end select
next i
for i=0 to 3
txtoutput.text +=srt(i)+a(i).tostring+vbcrlf
next
搜索更多相关主题的帖子: dim string srt case 
2006-10-27 21:18
梓风
Rank: 2
等 级:新手上路
威 望:4
帖 子:181
专家分:0
注 册:2006-10-22
收藏
得分:0 
Dim a(4) As Integer, ch As String, instring As String
Dim i As Integer
Dim srt As String() = {"大写字母", "小写字母", "数字字符", "其它字符"}
instring = TextBox2.Text
For i = 0 To instring.ToString.Length - 1
ch = instring.ToString.Chars(i)
Select Case ch
Case "A" To "Z"
'计算大写字母个数
a(0) = a(0) + 1
Case "a" To "z"
'计算小写字母个数
a(1) = a(1) + 1
Case "0" To "9"
'计算数字个数
a(2) = a(2) + 1
Case Else
'计算其他个数
a(3) = a(3) + 1
End Select
Next i
For i = 0 To 3
TextBox2.Text += srt(i) + a(i).ToString + vbCrLf
Next
这样才是对的,自己设置断点跟踪下,就明白了

等待相逢
2006-10-28 08:18
lsdm
Rank: 1
等 级:新手上路
帖 子:140
专家分:0
注 册:2006-1-7
收藏
得分:0 
谢谢梓风,有几句不明白,请指点一二,谢谢!
Dim srt As String() = {"大写字母", "小写字母", "数字字符", "其它字符"}
instring = TextBox2.Text
For i = 0 To instring.ToString.Length - 1
ch = instring.ToString.Chars(i)
这几句不太明白啊!

2006-10-28 12:00
梓风
Rank: 2
等 级:新手上路
威 望:4
帖 子:181
专家分:0
注 册:2006-10-22
收藏
得分:0 

Dim srt As String() = {"大写字母", "小写字母", "数字字符", "其它字符"}
定义一个string类型的数组
instring = TextBox2.Text
获取TextBox2文本的值
For i = 0 To instring.ToString.Length - 1
ch = instring.ToString.Chars(i)
遍历赋值给ch


等待相逢
2006-10-29 11:37
lsdm
Rank: 1
等 级:新手上路
帖 子:140
专家分:0
注 册:2006-1-7
收藏
得分:0 
多谢梓风的指点,我还是不太明白 a(0) = a(0) + 1以及后面类似的几句的意思,请您指点啊,谢谢!

2006-10-30 23:12
梓风
Rank: 2
等 级:新手上路
威 望:4
帖 子:181
专家分:0
注 册:2006-10-22
收藏
得分:0 
统计对应的{"大写字母", "小写字母", "数字字符", "其它字符"}中的个数的

等待相逢
2006-11-03 13:35
快速回复:[求助]dim srt as string()
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020814 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved