设窗体上有Text1、Text2两个文本框,并编写了下面的程序代码: Private Sub Text1_KeyPress(KeyAscii As Integer) If "A"

admin2015-08-28  17

问题 设窗体上有Text1、Text2两个文本框,并编写了下面的程序代码:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If "A" <= Chr(KeyAscii) And Chr(KeyAscii) <= "Z" Then
            KeyAscii = KeyAscii + (Asc("a") - Asc("A"))
        End If
        n = 0
        If KeyAscii = 13 Then
            For k = 1 To Len(Text1)
                ch$ = Mid(Text1, k, 1)
                If "a" <= ch And ch <= "z" Then n = n + 1
            Next k
            Text2 = n
        End If
    End Sub
程序运行时,在Text1文本框中输入"Visual Basic 6.0"后按回车键,则在Text2文本框显示的是

选项 A、11
B、16
C、Visual Basic 6.0
D、visual basic 6.0

答案A

解析 Text1_KeyPress过程中,先把输入的字符串中大小字母变成小写字母。当按下回车键后,执行For循环统计小写字母的个数。退出循环后把n值赋给Text2。选A)。
转载请注明原文地址:https://kaotiyun.com/show/YELp777K
0

最新回复(0)