Private Sub Command1_Click()
Dim a(99) As String, i As Integer
Randomize
For i = 0 To 99
a(i) = Chr(Asc("A") + Int(Rnd * 26))
Next
Text1.Text = Join(a, " ")
End Sub
这个问题有人问过了http://zhidao.baidu.com/question/538607993?&oldq=1
随机生成100个大写字母存于数组a中,并显示在text1中,字母间用空格隔开,在text2中输入一个大写字母,得出在数组a中出现的次数,在text3中显示。
Private arr(100)
Private Sub CommandButton1_Click()
Randomize
For i = 1 To 100
arr(i) = Chr(Int(Rnd * 26) + 65)
TextBox1.Text = TextBox1.Text & arr(i) & " "
Next
End Sub
Private Sub CommandButton2_Click()
Dim find As String
find = TextBox2.Text
TextBox3.Text = 0
For i = 1 To 100
If arr(i) = TextBox2.Text Then
TextBox3.Text = CInt(TextBox3.Text) + 1
End If
Next
End Sub