i have 1 textbox

in the keypress event this is my code


if keyascii >= 48 and keyascii <= 75 then
exit sub
else
keyascii = 0
end if


how can i erase the last value that im inputted in my textbox using vbkeyback?

god bless daniweb!

Not completely sure what you exactly want.
Here is my code to disable some user input and enable other

Instead of keypress use keydown

Select Case KeyCode
Case 0 to 7
KeyCode = 0
Case Is = 8
KeyCode = KeyCode
Case 9 to 31
KeyCode = 0
Case 32 to 127
KeyCode = KeyCode
Case 128 to 255
KeyCode = 0
End Select

--or--

Better off putting it in a module so you can call it any time

-- start module--
Function DisEsc(KeyCode As Integer) As Integer

Select Case KeyCode
Case 0 to 7
DisEsc = 0
Case Is = 8
DisEsc = KeyCode
Case 9 to 31
DisEsc = 0
Case 32 to 127
DisEsc = KeyCode
Case 128 to 255
DisEsc = 0
End Select
--end module--

--Form Code--

Private Sub Form_KeyDown(KeyCode As Integer)

KeyCode = DisEsc(KeyCode)

End Sub


get your ascii values at http://www.asciitable.com/

Hi,

Change your code to :

If KeyAscii <> 8 Then
    if keyascii >= 48 and keyascii <= 75 then
       exit sub
    else
       keyascii = 0
    end if
End If

Regards
Veena

thnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.