Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
How can we restrict users to enter 5 digits only in a userform textbox?
TIA |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
Hi,
I simple way is to set the maxlengrh property to 5. Right click the textbox, properties abd you'll see the propery of maxlength. Mike "sam" wrote: How can we restrict users to enter 5 digits only in a userform textbox? TIA |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
Hi Tia,
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 can we restrict users to enter 5 digits only in a userform textbox? TIA |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
You have to check yourself.
Option Explicit Private Sub CommandButton1_Click() MsgBox Me.TextBox1.Value End Sub Private Sub CommandButton2_Click() Unload Me End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim iCtr As Long Dim myStr As String Dim OkValue As Boolean myStr = Me.TextBox1.Value OkValue = True If Len(myStr) < 5 Then OkValue = False Else For iCtr = 1 To 5 If IsNumeric(Mid(myStr, iCtr, 1)) Then 'keep looking Else OkValue = False Exit For 'stop looking End If Next iCtr End If Cancel = Not (OkValue) End Sub Private Sub UserForm_Initialize() 'the cancel button 'allows the user to hit that button even if 'the entry in the textbox is invalid Me.CommandButton2.TakeFocusOnClick = False End Sub sam wrote: How can we restrict users to enter 5 digits only in a userform textbox? TIA -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
thanks a lot, this worked out great. we can set the max value from property
box, but do you know how we can set min values? "Mike H" wrote: Hi, I simple way is to set the maxlengrh property to 5. Right click the textbox, properties abd you'll see the propery of maxlength. Mike "sam" wrote: How can we restrict users to enter 5 digits only in a userform textbox? TIA |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
restrict user to enter 5 digits only
thanks a lot, this worked out great. we can set the max value from property
box, but do you know how we can set min values? "Eduardo" wrote: Hi Tia, 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 can we restrict users to enter 5 digits only in a userform textbox? TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
restrict user in excel to numbers below 100 | Excel Worksheet Functions | |||
Not able to enter more than 15 digits in a cell. | Excel Discussion (Misc queries) | |||
How do I enter a SSN but only display the last four digits? | Excel Discussion (Misc queries) | |||
Restrict User to specific cell | Excel Discussion (Misc queries) | |||
Restrict User Input | Excel Programming |