Por favor ayudenme necesito ingresar numeros solo de dos cifras o sea hasta 99 en un textbox
Prueba con esto:
Private Sub Text1_Change()
If Len(Text1.Text) > 2 Then
Text1.Text = Right$(Text1.Text, 2)
End If
End Sub
Y para que solo te salgan números pon la propiedad DataFormat del TextBox en Numbers
Espero haberte ayudado... :P
Salu2! ;)
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const ES_NUMBER As Long = &H2000&
Private Sub Form_Load()
With Text1
.MaxLength = 2
SetWindowLong .hwnd, GWL_STYLE, GetWindowLong(.hwnd, GWL_STYLE) Or ES_NUMBER
End With
End Sub
Si te refieres que permita el ingreso de sólo números de dos cifras puedes hacer así, también:
Establecer la Propiedad MaxLength del TextBox a 2 en tiempo de diseño o en tiempo de ejecución:
Private Sub Form_Load()
With Text1
.MaxLength = 2
End With
End Sub
Luego en el Evento KeyPress del TextBox
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13
Case 8, 46, 48 To 57
Case Else
KeyAscii = 0
Beep
End Select
End Sub
8 = borrado atráz. indispensable
46 = para que acepte el punto (.) para números decimales. sino, lo quitas
48 to 57 = dígitos del 0 hasta el 9