题库 题库

【简答题】

Dim an As Integer
Dim bn As Integer
Dim cn As Integer
Dim dn As Integer
Private Sub Command1_Click()
    Open App.Path & "\in5.txt" For Input As #1
    Do While Not EOF(1)
        Input #1, a$
        s = s & a$
    Loop
    Close 1
    Text1.Text = s
End Sub

参考答案

Private Sub Command2_Click()
'考生应编写的程序
    n = Len(Text1)
    For k = 1 To n
        ch = Mid(Text1, k, 1)
        If UCase(ch) = "A" Then
            an = an + 1
        End If
        If UCase(ch) = "B" Then
            bn = bn + 1
        End If
        If UCase(ch) = "C" Then
            cn = cn + 1
        End If
        If UCase(ch) = "D" Then
            dn = dn + 1
        End If
    Next k
    Text1 = an & " " & bn & " " & cn & " " & dn
End Sub
Private Sub Command3_Click()
    Open App.Path & "\out5.txt" For Output As #1
    Print #1, an, bn, cn, dn
    Close 1
End Sub

相关试题