Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default if char is number

How can I determine whether a char is a digit or a period by menas of VBA?
Example:
If char = 0 or char = 1 ... or char = 9 or char = "." Then
...

There is sure to be a shorter solution.

Regards,
Roman


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default if char is number

If IsNumeric(char) Then

Sharad

"Roman Töngi" wrote in message
...
How can I determine whether a char is a digit or a period by menas of VBA?
Example:
If char = 0 or char = 1 ... or char = 9 or char = "." Then
...

There is sure to be a shorter solution.

Regards,
Roman



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default if char is number

? isnumeric(".")
False
? isnumeric("5")
True


so
if Isnumeric(char) then
msgbox "It can be treated as a number"
else
msgbox "it can't be treated as a number"
End if

--
Regards,
Tom Ogilvy

"Roman Töngi" wrote in message
...
How can I determine whether a char is a digit or a period by menas of VBA?
Example:
If char = 0 or char = 1 ... or char = 9 or char = "." Then
...

There is sure to be a shorter solution.

Regards,
Roman




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default if char is number

Actually it should be
If IsNumeric(char) Or char = "." Then

in case you want to check if char is only a dot.
Sharad

"Roman Töngi" wrote in message
...
How can I determine whether a char is a digit or a period by menas of VBA?
Example:
If char = 0 or char = 1 ... or char = 9 or char = "." Then
...

There is sure to be a shorter solution.

Regards,
Roman



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default if char is number

My answer was incomplete as well. If you want to check if Char is a period
you would have to check that explicitly. However, if your use of char is
actually misleading and you want to check if a string is a number

char = 123.45

then Isnumeric(char) would be true.

if char ="A1123"

then isnumeric(char) would be false

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
? isnumeric(".")
False
? isnumeric("5")
True


so
if Isnumeric(char) then
msgbox "It can be treated as a number"
else
msgbox "it can't be treated as a number"
End if

--
Regards,
Tom Ogilvy

"Roman Töngi" wrote in message
...
How can I determine whether a char is a digit or a period by menas of

VBA?
Example:
If char = 0 or char = 1 ... or char = 9 or char = "." Then
...

There is sure to be a shorter solution.

Regards,
Roman








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default if char is number

just what I looked for,
thanks


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
How to determine char or number? Eric Excel Discussion (Misc queries) 4 February 9th 10 02:31 PM
How do I get a line under my number that is just 1 char more? megan Excel Discussion (Misc queries) 2 September 22nd 08 06:20 PM
FIND 1 char in cell of any 3 char =True Nastech Excel Discussion (Misc queries) 5 April 26th 08 02:17 PM
8500 cells with phone number(7 char.), wishing to add area code (10 char.) [email protected] Excel Discussion (Misc queries) 6 March 10th 06 05:13 PM
LIMIT NUMBER OF CHAR IN A COMBINE CELL rafaeljsg Excel Discussion (Misc queries) 1 October 5th 05 04:15 PM


All times are GMT +1. The time now is 12:59 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"