Vb 经典题型
1,文本出现字符次数最多的字母,及出现的次数
Dim a(1 To 26) As Integer
Dim max As Integer
n = Len(s)
For i = 1 To n
k = Asc(Mid$(s, i, 1))
If (k >= 65 And k <= 90) Then
a(k - 64) = a(k - 64) + 1
End If
If (k >= 97 And k <= 122) Then
a(k - 96) = a(k - 96) + 1
End If
Next
max = 0
For m = 1 To 26
If max < a(m) Then
max = a(m)
End If
Next
Text2 = max
For m = 1 To 26
If a(m) = max Then
l = m
End If
Next
Text1 = Chr(l + 64)
2,打印出菱形
Private Sub Form_Click()
For i = 1 To 5
For j = 1 To 6 - i
Print " ";
Next j
For j = 1 To 2 * i - 1
Print "*";
Next j
Print