VB程序题

VB程序题,第1张

1、KeyPress

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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11802528.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存