重复的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
Private Sub Text7_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 Text8_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 Text9_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 Text10_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 Text11_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 Text12_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 Text13_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 Text14_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 sub1(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)
call sub1(KeyAscii)
end sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
call sub1(KeyAscii)
end sub
'...........
Private Sub Text14_KeyPress(KeyAscii As Integer)
call sub1(KeyAscii)
end sub
