2-character limit on InputBox

G

Guest

Hi All........
I am using the following line to present the user with a opportunity to
input some data. I would like to accept 0, 1, or 2 characters and reject 3
or more characters for a re-do.....help please

choice1 = InputBox("Enter PlannerCode to search for:")

TIA
Vaya con Dios,
Chuck, CABGx3
 
G

Guest

Neither InputBox nor Application.InputBox have any kind of validation or
input mask so if you either have to validate the input after the fact or
create a form with a text box to do what you want to do. My preference would
be for the form but to each his own...
 
G

Guest

Ok, thanks Jim.......I'll look doing it another way.......you've saved me
from spinning my wheels trying to make this one work.

Vaya con Dios,
Chuck, CABGx3
 
J

Jim Cone

Chuck,
Maybe this...

Sub WhoAreYou()
Dim choice1 As String
Dim strMsg As String
Do
choice1 = InputBox("Enter PlannerCode to search for:", "Chuck Wants to Know", strMsg)
If Len(choice1) < 3 Then Exit Do
strMsg = "One or two characters only"
Loop
If Len(choice1) = 0 Then
Exit Sub
End If
End Sub
'--
Regards,
Jim Cone


"CLR" <[email protected]>
wrote in message
Hi All........
I am using the following line to present the user with a opportunity to
input some data. I would like to accept 0, 1, or 2 characters and reject 3
or more characters for a re-do.....help please

choice1 = InputBox("Enter PlannerCode to search for:")

TIA
Vaya con Dios,
Chuck, CABGx3
 
G

Guest

BINGO JIM!!!!..........your code works like a champ. Sorry I didn't get back
sooner but I had a computer crash due to lightning yesterday just after you
posted and I didn't get to try it until this morning.......

Happy camper here...........thanks again

Vaya con Dios,
Chuck, CABGx3
 

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