因为必要参数没传递进去,假如说你传递 KeyAscii变量到 JCSJ 过程里,那在过程里修改还是不影响控件的数据。
你要想方便,可以用这种方式:
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = KeepNumAsc(KeyAscii) '过滤
End Sub
Function KeepNumAsc(KeyAscii As Integer) As Integer
Select Case KeyAscii
Case Asc("0") To Asc("9"), vbKeyBack, Asc(".") '允许0~9数字和退格键和符号“.”
KeepNumAsc = KeyAscii
Case Else
KeepNumAsc = 0
Beep '其他的发出Beep声音
MsgBox "只能输入数字!"
End Select
End Function
私人:子Text1_KeyPress(KeyAscii作为整数)
如果KeyAscii = 46或(KeyAscii> = 48和KeyAscii <= 57)或KeyAscii = 8然后
其他
KeyAscii = 0 BR />结束如果
结束小组
调用过程时记得传递必要参数。。。-_-||