Private Sub Command1_Click()
Cls
total (Text1.text)
End Sub
Sub total(text) FirstChr = Left(text, 1)'截取左边第一个字母 times = 0 For i = 1 To Len(text) If Mid(text, i, 1) = FirstChr Then'统计第一个字母出现的次数 times = times + 1 End If Next newstr = Replace(text, FirstChr, "")'清除字符串中的第一个字母 Print FirstChr & "出现次数为" & times If newstr <> "" Then total (newstr) '如果字符串不为空,继续调用,直到字符串为空 End If
Private Sub Command1_Click()
'以下是产生-50到50之间10个不重复的数字
Cls
s = "" Randomize Dim i As Integer, j As Integer Dim a(10) As Integer For i = 0 To 9
start: a(i) = Int((50 + 50 + 1) * Rnd + -50) For j = 0 To i - 1 If a(j) = a(i) Then GoTo start End If Next Next For i = 0 To 9 s = s & CStr(a(i)) & ";" Next Print "-50到50之间产生的10数字为: " Print s
'以下是冒泡发排序 For i = 0 To 9 For j = i + 1 To 9 If a(i) > a(j) Then t = a(i) a(i) = a(j) a(j) = t End If Next j Next i For i = 0 To 9 Print a(i) Next i
End Sub