Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting minimum value in text box 1

Status
Not open for further replies.

smurf01

IS-IT--Management
Jul 6, 2002
470
GB
In Excel you can set the maximum number of characters in a text box. Is there anyway to set a minimum value also

i.e. i want a text box to only accept six numbers or letters Regards

Paul
 
You can validate upon triggering the exit event for the textbox. You could even pre-fill the text with whatever the proper form for the field is (e.g. 000000) and use the change event to adjust the field after each key entry. Exactly how depends on your application.
Rob
[flowerface]
 
Rob,
How would I validate the exit event please ?? Regards

Paul
 
In a crude form, something like:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox1) <> 6 Then
MsgBox &quot;This field needs to be exactly 6 characters&quot;
Cancel = True
End If
End Sub
Rob
[flowerface]
 
Rob,
Excellent Thank You Regards

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top