(不区分字母的大小写)
要求: 所有结果按照键值对的方式输出到处输出窗口 如:<字符>:<出现次数>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim M(100) As Integer
Dim N(128) As Integer
Randomize()
For i = 0 To 99
M(i) = Rnd() * 127
N(M(i)) = N(M(i)) + 1
Next
For i = 48 To 58
MsgBox ( Chr(i) & " : " & N(i))
Next
For i = 65 To 90 'A-Z
MsgBox(Chr(i) & " : " & N(i) + N(i + 32))
Next
End Sub
我这样写可以输出,但是每输出一个就出现一个Msgbox,怎么能一次输出,最好输出在Label里面。
VB 关于输出!随机产生100个ASCII字符分别求0~9等10个数字、26个字母的出现次数
答案:2 悬赏:20 手机版
解决时间 2021-02-21 10:21
- 提问者网友:半生酒醒
- 2021-02-20 16:14
最佳答案
- 五星知识达人网友:傲气稳了全场
- 2021-02-20 16:42
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim M(100) As Integer
Dim N(128) As Integer
Randomize()
For i = 0 To 99
M(i) = Rnd() * 127
N(M(i)) = N(M(i)) + 1
Next
Dim Txt as String=""
For i = 48 To 58
Txt += Chr(i) & " : " & N(i) & VbCrLf
Next
For i = 65 To 90 'A-Z
Txt += Chr(i) & " : " & N(i) + N(i + 32) & VbCrLf
Next
Label1.text=Txt
End Sub
Dim M(100) As Integer
Dim N(128) As Integer
Randomize()
For i = 0 To 99
M(i) = Rnd() * 127
N(M(i)) = N(M(i)) + 1
Next
Dim Txt as String=""
For i = 48 To 58
Txt += Chr(i) & " : " & N(i) & VbCrLf
Next
For i = 65 To 90 'A-Z
Txt += Chr(i) & " : " & N(i) + N(i + 32) & VbCrLf
Next
Label1.text=Txt
End Sub
全部回答
- 1楼网友:时间的尘埃
- 2021-02-20 17:52
dim m(100) as integer dim n(128) as integer '产生随机字符 randomize timer for i = 0 to 99 m(i) = rnd * 127 n(m(i)) = n(m(i)) + 1 '统计 next '输出 0-9 出现次数 for i = 48 to 58 print chr(i) & " : " & n(i) next '输出a-z 出现次数(含对应小写) for i = 65 to 90 'a-z print chr(i) & " : " & n(i) + n(i + 32) next
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯