Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
validation
hello all,
i am trying to put validation on a textbox in a userform. i currently have this bit of code and it does not work. all i need is for it to except a 0 or 1 anything else would produce a message box stating that a 0 or 1 is needed. Private Sub nailbase_Change() If nailbase.Value 1 Then MsgBox "Number must be a 0 or 1." End Sub -- Thank You in advance, Brian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
validation
Since you're only accepting 0 or 1, how about using a checkbox (0 if unchecked
or 1 if checked) -- or even a pair of option buttons. I would think that it would be easier for the user and less work for you... But Textboxes return strings: Private Sub nailbase_Change() If nailbase.Value = "1" _ or nailbase.value = "0" Then 'do nothing, it's ok else MsgBox "Number must be a 0 or 1." end if End Sub Brian wrote: hello all, i am trying to put validation on a textbox in a userform. i currently have this bit of code and it does not work. all i need is for it to except a 0 or 1 anything else would produce a message box stating that a 0 or 1 is needed. Private Sub nailbase_Change() If nailbase.Value 1 Then MsgBox "Number must be a 0 or 1." End Sub -- Thank You in advance, Brian -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
validation
very good point Dave on using the check boxes. i will look into changing my
userform around. the code works good also. thank you for your time, and have a good day. -- Brian "Dave Peterson" wrote: Since you're only accepting 0 or 1, how about using a checkbox (0 if unchecked or 1 if checked) -- or even a pair of option buttons. I would think that it would be easier for the user and less work for you... But Textboxes return strings: Private Sub nailbase_Change() If nailbase.Value = "1" _ or nailbase.value = "0" Then 'do nothing, it's ok else MsgBox "Number must be a 0 or 1." end if End Sub Brian wrote: hello all, i am trying to put validation on a textbox in a userform. i currently have this bit of code and it does not work. all i need is for it to except a 0 or 1 anything else would produce a message box stating that a 0 or 1 is needed. Private Sub nailbase_Change() If nailbase.Value 1 Then MsgBox "Number must be a 0 or 1." End Sub -- Thank You in advance, Brian -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Validation Data using Validation Table cell range..... | Excel Discussion (Misc queries) | |||
Data validation with validation lists and combo boxs | Excel Discussion (Misc queries) | |||
Validation (Drop down list vs simple text length validation) | Excel Programming | |||
Validation (Drop down list vs simple text length validation) | Excel Programming | |||
Validation (Drop down list vs simple text length validation) | Excel Programming |