vba problem with isnumeric

  • Thread starter Jean-Pierre D via OfficeKB.com
  • Start date
J

Jean-Pierre D via OfficeKB.com

Hi,

I have a simple question for the following code:

Private Sub OnlyNumbers(ctl As Object)
With ctl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, alleen getallen toegestaan"
.Value = vbNullString
.SetFocus
MsgBox "numtest"
End If
End With
End Sub

This code checks if the input in a txt box is numeric. It works fine !
My problem: I only want to check if the left first character of the input is
numeric !
I thought it should be possible to change the line

If Not IsNumeric(.Value) And .Value <> vbNullString Then

so it only looks at the first character that is input by the user.
Can anyone help me please?
Thanks,
Pierre
 
D

David McRitchie

Hi Jean-Pierre,

If Not IsNumeric(Left(.Value, 1)) And .Value <> vbNullString Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top