Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default restrict users to input atleast five characters

how do we restrict user to input minimun characters in a text box on userform.

for eg. I want to make zip code field such that users need to input atlest 5
characters, and not anything less then that.

thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,276
Default restrict users to input atleast five characters

Hi ,

Go to visual basic, view object, position in the textbox you want to enter
the limit, then choose Categorized, under Behavior look into MaxLength and
enter 5 there



"sam" wrote:

how do we restrict user to input minimun characters in a text box on userform.

for eg. I want to make zip code field such that users need to input atlest 5
characters, and not anything less then that.

thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default restrict users to input atleast five characters

Hi,

There's the maxlength that you asked about earlier but no minlength so you
have to check yourself. Right click the textbox, view code and try this code

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox1.Text) < 5 Then
With Me.TextBox1
.Text = ""
.SetFocus
End With
MsgBox "A properly formatted zipcode please"
End If

End Sub

Mike

"sam" wrote:

how do we restrict user to input minimun characters in a text box on userform.

for eg. I want to make zip code field such that users need to input atlest 5
characters, and not anything less then that.

thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default restrict users to input atleast five characters

You could use this Exit event code for the TextBox (assumed to be named
TextBox1 for this example)...

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox1.Text) 0 And Len(TextBox1) < 5 Then
Cancel = True
MsgBox "Your entry must be at least 5 characters long."
End If
End Sub

As written, the code allows the user to exit the TextBox if there is no
entry in it (that is what the 0 test provides for).

--
Rick (MVP - Excel)


"sam" wrote in message
...
how do we restrict user to input minimun characters in a text box on
userform.

for eg. I want to make zip code field such that users need to input atlest
5
characters, and not anything less then that.

thanks in advance


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict Users Restrict Users Excel Discussion (Misc queries) 1 January 12th 09 05:27 PM
how to restrict users on what options they can choose? TG Excel Programming 1 December 11th 08 10:11 PM
how do you restrict the users from copying and pasting Raja Excel Discussion (Misc queries) 1 May 14th 08 01:24 PM
restrict users Restricted user access for exel workbook Excel Worksheet Functions 0 March 15th 06 03:27 PM
Is there any way for me to allow or restrict individual users' ab. hsobah Excel Worksheet Functions 1 January 14th 05 09:26 PM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"