Mình có một loạt textbox: textbox1, textbox2, textbox3....với định dạng nhập dữ liệu là giống nhau cho tất cả textbox
H mình muốn hỏi là làm sao thu gọn các code bằng vòng lặp mà không thay đổi thuộc tính nhập vào các textbox như trên. Thank trước.
Mã:
Private Sub TxtB1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.txtb1.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtB2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.txtb2.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtB3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, Me.txtb3.Text, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
......