vb keypress事件怎么触发?
Dimx%,y%,z%PrivateSubText1_KeyPress(KeyAsciiAsInteger)Dimc$c=Chr(keyscii)IfUCase(c)>=...
Dim x%, y%, z%
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim c$
c = Chr(keyscii)
If UCase(c) >= "A" And UCase(c) <= "Z" Then
x = x + 1
ElseIf c >= "0" And c <= "9" Then
y = y + 1
Else
z = z + 1
End If
If keyscii = 13 Then
Print x, y, z
End If
End Sub
我不知道怎么触发这个事件,求指导! 展开
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim c$
c = Chr(keyscii)
If UCase(c) >= "A" And UCase(c) <= "Z" Then
x = x + 1
ElseIf c >= "0" And c <= "9" Then
y = y + 1
Else
z = z + 1
End If
If keyscii = 13 Then
Print x, y, z
End If
End Sub
我不知道怎么触发这个事件,求指导! 展开
1个回答
展开全部
keyscii写错了,少了A
Dim x%, y%, z%
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim c$
c = Chr(KeyAscii)
If KeyAscii = 13 Then'如果回车不想计算在内的话,就放在前面
Print x, y, z
Exit Sub
End If
If UCase(c) >= "A" And UCase(c) <= "Z" Then
x = x + 1
ElseIf c >= "0" And c <= "9" Then
y = y + 1
Else
z = z + 1
End If
End Sub
追问
改过来 然后再text里输入还是没反应啊,怎么触发这个事件呀?
我是照着课本上打的!
追答
检察一下按钮名有没有写错,看看name属性是不是Text1。附件打开看看。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |