我有userbox和textboxes。文本框限制某些字符的输入,或者更确切地说允许输入数字逗号和点。代码在文本框的key_press
事件范围内。只要下面的代码在key_press
事件中,一切正常。当我使用来自不同子代码的相同代码输入call private sub
时,它不起作用。
为什么它不起作用?
Key_press
事件中的代码:
Private Sub netto_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc("-")
Case Else
KeyAscii = 0
End Select
End Sub
在Key_press
事件中使用call sub的代码:
Private Sub netto_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Call klawisze
End Sub
Private Sub klawisze()
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc("-")
Case Else
KeyAscii = 0
End Select
End Sub
答案 0 :(得分:1)
你在哪里接近正确的解决方案。您只需要在KeyAscii
子区域中传递参数klawisze
(它接受相应的参数:ByVal KeyAscii As MSForms.ReturnInteger
):
Private Sub netto_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Call klawisze(KeyAscii)
End Sub
Private Sub klawisze(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc("-")
Case Else
KeyAscii = 0
End Select
End Sub