954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do I limit text char in Combo box?

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

x38class
Newbie Poster
24 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

use keyascii code on keypress event

lkexpert
Newbie Poster
6 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

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

x38class
Newbie Poster
24 posts since May 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You