Transformar en Función para varios TextBox
Esta
Sub Sleccionar_TextBox() On Error Resume Next nombretextbox = MPAG.txtmoc6(MPAG.txtmoc6.Text) nombretextbox = MPAG.txtmoc8(MPAG.txtmoc8.Text) 'etc valor = nombretextbox If Not (KeyAscii >= 48 And KeyAscii <= 57) Then KeyAscii = 0 '<-- Esta linea borra la tecla presionada equivocadamente MsgBox "Ingrese SOLO números en " & valor, vbOKOnly + vbInformation, Title:="CARACTER NULO" End If If Len(valor) = 12 Then KeyAscii = 0: MsgBox "MAX permitido en Telf 1 y 2, 12 dígitos": Exit Sub 'Para Guion Select Case Len(valor) Case 4 valor.Text = valor & "-" End Select End Sub Para esto y mas si la necesidad lo ameita 'Solo números, guion y cantidad caracteres Private Sub txtmoc6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call Sleccionar_TextBox 'VAlor Call número End Sub Private Sub txtmoc8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call Sleccionar_TextBox 'VAlor Call número End Sub
Feliz noche y mejor domingo.
1 respuesta
Respuesta de Dante Amor
1