View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default check is input textboxes is numeric on userform

I don't know any way to do this unless you are willing to create a custom
class. For the 20 textboxes you have it is probably easiest just to do as
you have done. If you think you may need to do this repeatedly in the
future, look into class modules and custom classes to create your own objects
that use existing objects but add new features and functionality. Too much
to get into here but lots of online references if you search.
--
- K Dales


"Jean-Pierre D via OfficeKB.com" wrote:

Hi,

I have a multipage userform.
on one of the pages there are 10 text boxes that may only contain numbers( or
a percentage)

I now use the following code:

Private Sub nw_premieNP_change()
OnlyNumbers
End Sub

and then the following sub:

Private Sub OnlyNumbers()
With nw_premieNP.ActiveControl
If Not IsNumeric(.Value) And .Value < vbNullString Then
MsgBox "Sorry, alleen getallen toegestaan"
.Value = vbNullString
End If
End With
End Sub

This works perfectly but i have to do this for each textbox. so i get 20 subs
!
Is there a better way to do this for all the textboxes in the userform page?

Thanks,
Jean-Pierre


--
Message posted via http://www.officekb.com