Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default vba problem with isnumeric

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


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default vba problem with isnumeric

Hi Jean-Pierre,

If Not IsNumeric(Left(.Value, 1)) And .Value < vbNullString Then
---
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm


"Jean-Pierre D via OfficeKB.com" wrote in message ...
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


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default vba problem with isnumeric

use LEFT

IsNumeric(LEFT(.Value,1))


Mangesh




"Jean-Pierre D via OfficeKB.com" wrote in message
...
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


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
When does ISNUMERIC point to a number? davidm Excel Programming 2 July 27th 05 12:51 PM
opposite of IsNumeric thephoenix12 Excel Discussion (Misc queries) 10 June 24th 05 07:37 PM
opposite of IsNumeric thephoenix12[_3_] Excel Programming 2 June 23rd 05 10:29 PM
IsNumeric Test scott Excel Programming 5 February 8th 05 07:59 PM
Not IsNumeric not working - or is it me? Ed Excel Programming 3 January 6th 05 11:30 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"