if char is number

  • Thread starter Thread starter Roman Töngi
  • Start date Start date
R

Roman Töngi

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
 
? 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
 
Actually it should be
If IsNumeric(char) Or char = "." Then

in case you want to check if char is only a dot.
Sharad
 
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
 

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

Back
Top