1,e.keychar
2,c
3,"A"c,"E"c,"I"c,"O"c,"U"c
4,c=chr(13)
'说实话,这样的统计不正确,比如按退格,删除等.应做到textchanged中或Validated中更合理
Dim countY%, countC%
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim c As Char
c = ucase(e.keychar)
If "A" <= c And c <= "Z" Then
Select Case c
Case "A","E","I","O","U"
‘元音字母
countY = countY + 1
Case Else
countC = countC + 1
End Select
End If
If asc(c)=13 Then ‘判断是否按回车键 (回车键的ASCII值为13)
MsgBox("元音字母有" & countY & "个")
MsgBox("其他字母有" & countC & "个")
End If
End Sub