I have a combo box I want to limit user input

I have the following code on 'keypress' event

dim keyascii as short = asc(e.keychar)
dim s as string

if keyascii = 45 then
exit sub
end if
' allow '-' key

s=checkalphanumeric(s,"AN")
' My function to check keyascii
's returns 0-9, a-z, A-Z if true

if s="" then
exit sub
end if

e.handled=true

end sub

I have same code used for text boxes except 'e' is 'eventargs' & it works

I can still type anything in my combo box, am I missing something?

any help much appreciated

use keyascii code on keypress event

Sorry it took so long to reply, & thank you for taking an interest in my problem

It took a while to determine all the options I wanted to exclude, but the use of keyascii was most useful

Thanks again

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.