Textbox Validation

L

leerem

Hi,
I have a userform that users enter the Drivers Name of the vehicle
into, plus other data. User's being how they are, tend to enter other
meanings as well, I've managed to sort out the unwelcome messages and any
numerical entries, but how do i prevent an entry such as "pppppppppp",
"kkkkkkkkkk" or even something like "po po po po" as an example.

I've tried coding this but have had no luck. to be honest I'm a bit baffled
as to how to overcome this. Please help

Regards Lee
 
S

SteAXA

Hi, i solved a similar problem (i'd problem with data) like this:

Sub Test_Number()
Dim n As Integer

On Error GoTo InvalidValue
n = CDec(tbValori)

InvalidValue:
If Err.Number = 13 Then
MsgBox "Invalid data: it's must be a number!"
End If

End Sub

I wish to be helpful.
 
L

leerem

many thanks for replying, the solution that you applied is for isolating text
only. I need assistance with resolving repeated text, as in my previous
thread. Can you assist with this?
 
H

Helmut Meukel

leerem said:
Hi,
I have a userform that users enter the Drivers Name of the vehicle
into, plus other data. User's being how they are, tend to enter other
meanings as well, I've managed to sort out the unwelcome messages and any
numerical entries, but how do i prevent an entry such as "pppppppppp",
"kkkkkkkkkk" or even something like "po po po po" as an example.

I've tried coding this but have had no luck. to be honest I'm a bit baffled
as to how to overcome this. Please help

Regards Lee


I don't think you can rule out all bogus entries. You can try, but...
Out of the top of my head: use Mid(entry$, p, 1) in a for next loop like

Function IsBogus(entry as string)
dim ch as string
for p = 1 to len(entry) - 2
ch = mid(entry, p, 1)
if mid(entry, p, 3) = String(3, ch) then
IsBogus = true
exit function
endif
next p
...
End Function

How to deal with names like
Donald Duck,
Mickey Mouse,
Jane Doe,

you can make a list to check against, but..

Helmut.
 
S

SteAXA

I don't understand if you must do this for each character typed or you must
do this for more text box?
 
L

leerem

Great, that's the type of code that should do it! I'll add it in and let you
know.....
Many thanks

Lee
 
H

Helmut Meukel

To catch things like "po po po po" you could use a similar approach,
step with mid(entry, p, 3) through the string and compare with mid(entry, p+3,
3)
For entries like "sdfghjkl" you can check for consecutive consonants, step
through the string with mid(entry, p, 1) and count the consonants, reset the
counter every time it's a vowel or a space. If counter is 4 (or 5) then it's
bogus.
To allow for some eastern european names 5 might be better.

Helmut.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top