ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validate Alphanumeric (https://www.excelbanter.com/excel-programming/281547-validate-alphanumeric.html)

Garry Jones

Validate Alphanumeric
 
I want to validat a user entry into a textbox.

I use trim to remove blanks and I test for NULL

But if the user presses Ctrl+Tab it enters a tab character in the
textbox.

The entry the user makes can contain numbers or letters, how do I stop
ctrl+tab from entering a tab in the textbox?

I am using keydown and keypress to look for "tab" (tab forwards) and
"Shift and Tab" (tab backwards). It works, the tab key does tab to the
next box, "Shift and Tab" does tab to previous box, but "Ctrl and Tab"
enters a tab in the textbox, I have found a reference that ctrl and tab
will be ignored when multiline=false (which it is). Can I simply ignore
off "Ctrl+Tb"?

A better solution would be to test that input is alphanumeric as I may
run accross other strange user inputs, I can only find IsNumeric in
Excel VB. Anyway of only allowing "Shift+Tab", Tab, Backspace, arrows
and alphanumeric input? (Note I also have to allow Swedish letters åäö
and ÅÄÖ. (But I know the ascii values for these).

Garry Jones
Sweden

BrianB

Validate Alphanumeric
 
How about using the CLEAN() worksheet function which removes all
non-printing characters. eg. ..
mystring = Application.WorksheetFunction.Clean(Me.TextBox1.Va lue)

Regards
BrianB
================================================== ==


Garry Jones wrote in message ...
I want to validat a user entry into a textbox.

I use trim to remove blanks and I test for NULL

But if the user presses Ctrl+Tab it enters a tab character in the
textbox.

The entry the user makes can contain numbers or letters, how do I stop
ctrl+tab from entering a tab in the textbox?

I am using keydown and keypress to look for "tab" (tab forwards) and
"Shift and Tab" (tab backwards). It works, the tab key does tab to the
next box, "Shift and Tab" does tab to previous box, but "Ctrl and Tab"
enters a tab in the textbox, I have found a reference that ctrl and tab
will be ignored when multiline=false (which it is). Can I simply ignore
off "Ctrl+Tb"?

A better solution would be to test that input is alphanumeric as I may
run accross other strange user inputs, I can only find IsNumeric in
Excel VB. Anyway of only allowing "Shift+Tab", Tab, Backspace, arrows
and alphanumeric input? (Note I also have to allow Swedish letters åäö
and ÅÄÖ. (But I know the ascii values for these).

Garry Jones
Sweden



All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com