hello please help me on this i want to use ascii but all i want i will not use keypress only my cmdadd...is this possible without using keypress?..hoping for your positive responds....


sample

public function keytrap(keyascii as integer)

if keyascii >=48 and keyascii<=57 then
msgbox "invalid input"
exit function
end if

end function

public sub txt1.text(keyascii as integer)
call keytrap(keyascii)
end sub

but i want to call keytrap in my cmdadd...is this possible? please help me on this...

Hi jemz,
if i understand right then you have to call the keytrap function in the Keypress event of command button...
(*The keypress event you will find it by double clicking on the command button, up & right the dropdown list which its value is "Click" -> change it.)

Good luck..

hi jemz,

I assume that you are using a text box and a command button, and you have to check if the text box has only numbers , without using the key press event of the text box and by using the click event of the command button.

if so... then
you can put a loop in the on click event of the command button, using the mid function split the string in text box and check character by character if it is a number if it is not a number set some flag as false(or what ever you want), after the end of the loop if the flag is false display a message box stating that the value entered is not a valid number...

more simple way to do it is (if u dont want the ascii), use IsNumeric() function

hope this will help you

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.