重复的text内容请达人帮忙精简 送分哦
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
重复的text内容我把text2~text5 删除 然后复制4份text1用数组控件精简成
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
之后
Private Sub Text1_KeyPress(KeyAscii As Integer)或
Private Sub Text1(i)_KeyPress(KeyAscii As Integer)
都不能执行啊 请帮忙解决
[解决办法]
1,控件数组
步骤
放textbox在form里面,然后copy paste声成控件数组
然后再keypress中写
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
Dim Numbers As String
Numbers = "1234567890 " + Chr(8) + Chr(46)
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub