转换/过滤用户输入的文本时访问怪异
Access Weirdness when converting / filtering user entered text
谁能解释一下为什么会这样:
Private Sub PartNum_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 47 To 57
KeyAscii = KeyAscii
Case 97 To 122
KeyAscii = KeyAscii - 32
Case Else
KeyAscii = 0
End Select
End Sub
但是为什么这不起作用:
Function gUC(ByVal gKey As Integer) As Integer
Select Case gKey
Case 47 To 57
gKey = gKey
Case 97 To 122
gKey = gKey - 32
Case Else
gKey = 0
End Select
End Function
Private Sub PartNum_KeyPress(KeyAscii As Integer)
KeyAscii = gUC(KeyAscii)
End Sub
我的表单上有多个字段,我想像这样过滤,宁愿只调用一个函数,而不是为每个字段重写代码
我认为您没有正确返回值。
Function gUC(ByVal gKey As Integer) As Integer
Select Case gKey
Case 47 To 57
gUC= gKey
Case 97 To 122
gUC= gKey - 32
Case Else
gUC= 0
End Select
End Function
谁能解释一下为什么会这样:
Private Sub PartNum_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 47 To 57
KeyAscii = KeyAscii
Case 97 To 122
KeyAscii = KeyAscii - 32
Case Else
KeyAscii = 0
End Select
End Sub
但是为什么这不起作用:
Function gUC(ByVal gKey As Integer) As Integer
Select Case gKey
Case 47 To 57
gKey = gKey
Case 97 To 122
gKey = gKey - 32
Case Else
gKey = 0
End Select
End Function
Private Sub PartNum_KeyPress(KeyAscii As Integer)
KeyAscii = gUC(KeyAscii)
End Sub
我的表单上有多个字段,我想像这样过滤,宁愿只调用一个函数,而不是为每个字段重写代码
我认为您没有正确返回值。
Function gUC(ByVal gKey As Integer) As Integer
Select Case gKey
Case 47 To 57
gUC= gKey
Case 97 To 122
gUC= gKey - 32
Case Else
gUC= 0
End Select
End Function