Thread: validation
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Brian Brian is offline
external usenet poster
 
Posts: 683
Default 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