2、KeyAscii >=48 AND KeyAscii <=57
3、Text2.Text &Chr(KeyAscii)
以上是在Text2上将每次符合条件的字符都依次连接起来显示。如果是每次要在Text2上只显示一个字符,则将第3空改为:
Chr(KeyAscii)
是不是这个效果?建一个Text1。代码如下。
==========================
Private Sub Form_Load()
Text1.Locked = True
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKey0 To vbKey9
Text1.Text = Text1.Text + Chr(KeyAscii)
Case vbKeyDelete
If InStr(1, Text1.Text, ".") = 0 Then Text1.Text = Text1.Text + "."
Case vbKeyBack
If Len(Text1.Text) >0 Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Select
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)