Visual Basic - Ayuda

Life is soft - evento anual de software empresarial
 
Vista:

Ayuda

Publicado por lissi (81 intervenciones) el 01/03/2005 20:20:12
Hola programadores :
Estoy usando esta sentencia para que me permita teclear solo numeros, y funciona muy bien pero cuando presione backspace para borrar NO BORRA , que deberia hacer para que borre con esta tecla ??

If InStr("0123456789.,", Chr(KeyAscii)) = 0 Then KeyAscii = 0
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda

Publicado por ChaRLinux (60 intervenciones) el 01/03/2005 21:02:52
mira no borra porque utilizas el keyascii =0 y no permite modificar el texto
loque puedes hacer es lo siguiente
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

Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000&

Public Function SetNoNumbers(txt As TextBox, Flag As Boolean)
Dim curstyle As Long
Dim newstyle As Long

curstyle = GetWindowLong(txt.hwnd, GWL_STYLE)

If Flag Then
curstyle = curstyle Or ES_NUMBER
Else
curstyle = curstyle And (Not ES_NUMBER)
End If

SetNoNums = SetWindowLong(txt.hwnd, GWL_STYLE, curstyle)
txt.Refresh
End Function

Private Sub form_load()
Call SetNoNumbers(Text1, True)
End Sub

espero te sirva
ChaRLinux Corporation

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda

Publicado por aaa (54 intervenciones) el 01/03/2005 21:51:31
mucha vaina haces charlinux, te envio a tu corre Lissi.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar