我刚学不久。不过接触很久了。TextBox_KeyPress在我这里,怎么第一个值总是能传入呢。等我贴图。
Private Sub txtedit1_KeyPress(KeyAscii As Integer)
Dim Numbers As String '允许输入的字符
If flex1.Col = 5 Then '第5列
' MsgBox "flex1.Col = 5"
Numbers = "1234567890" + Chr(46) + Chr(8)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
'删除回车符,以消除嘟嘟声。
If KeyAscii = Asc(vbCr) Then KeyAscii = 0
End Sub
''限定第5列只能输入数字。方法一
'Private Sub flex1KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
'Dim Numbers As String '允许输入的字符
'If flex1.Col = 5 Then '第5列
' MsgBox "flex1.Col = 5"
' Numbers = "1234567890" + Chr(46) + Chr(8)
' If InStr(Numbers, Chr(KeyAscii)) = 0 Then
' KeyAscii = 0
' End If
'End If
'End Sub
''限定第5列只能输入数字。方法二
'Private Sub flex1_change()
'MsgBox "第5列必须输入数字"
' If flex1.Col = 5 Then
' If Not IsNumeric(.Text) Then
' MsgBox "第5列必须输入数字"
' End If
' End If
' End Sub