2008-05-23 10:07:13*~葉子~*

計算字母(VB)

Private Sub Form_Activate()
Dim i As Integer
Dim j As Integer
Dim n As String
Dim D(97 To 122) As Integer

Open App.Path & ”1.txt” For Input As #1
Do
Line Input #1, n
For i = 1 To Len(n)
For j = 97 To 122
If Asc(Mid(n, i, 1)) = j Then D(j) = D(j) + 1
Next j
Next i
Loop Until EOF(1)

For i = 97 To 122
Print ”字元” & Chr(i) & ”:” & D(i) & ”個”
Next i
Close #1
End Sub