469,366 Members | 2,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

can ASP check if an object is an integer?

Sorry for the dumb question, but what is the function in ASP to see if an
object / string is an integer?

I want to check the contents of a form, and if it's an integer, i.e a
number, do something, else if it's a word do something else, and I'm not
sure howto?

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Jul 19 '05 #1
9 37279
If IsNumeric(String_To_Check) Then
'// True
'// Do something
Else
'// False
'// Do something else
End If

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
news:cd**********@ctb-nnrp2.saix.net...
Sorry for the dumb question, but what is the function in ASP to see if an
object / string is an integer?

I want to check the contents of a form, and if it's an integer, i.e a
number, do something, else if it's a word do something else, and I'm not
sure howto?

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends (John 15:13).

Jul 19 '05 #2
Aha, thanx very much :)

btw, is there a manual / website with all the classis ASP commands /
functions / etc?

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Steven Burn" <pv*@noyb.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
| If IsNumeric(String_To_Check) Then
| '// True
| '// Do something
| Else
| '// False
| '// Do something else
| End If
|
| --
|
| Regards
|
| Steven Burn
| Ur I.T. Mate Group
| www.it-mate.co.uk
|
| Keeping it FREE!
|
|
| "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| news:cd**********@ctb-nnrp2.saix.net...
| > Sorry for the dumb question, but what is the function in ASP to see if
an
| > object / string is an integer?
| >
| > I want to check the contents of a form, and if it's an integer, i.e a
| > number, do something, else if it's a word do something else, and I'm not
| > sure howto?
| >
| > --
| >
| >
| > Kind Regards
| > Rudi Ahlers
| > +27 (82) 926 1689
| >
| > Greater love has no one than this, that he lay down his life for his
| friends
| > (John 15:13).
| >
| >
|
|
Jul 19 '05 #3
Ok, one more question, how do I use this, if I want to checkif it's not an
integer.

I want to check two things, like so:

if company_count = 0 and Is(not?)Numeric(industry) then
// stuff here
end if

i.e. If company_count = 0, and industry is not an integer?
--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Steven Burn" <pv*@noyb.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
| If IsNumeric(String_To_Check) Then
| '// True
| '// Do something
| Else
| '// False
| '// Do something else
| End If
|
| --
|
| Regards
|
| Steven Burn
| Ur I.T. Mate Group
| www.it-mate.co.uk
|
| Keeping it FREE!
|
|
| "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| news:cd**********@ctb-nnrp2.saix.net...
| > Sorry for the dumb question, but what is the function in ASP to see if
an
| > object / string is an integer?
| >
| > I want to check the contents of a form, and if it's an integer, i.e a
| > number, do something, else if it's a word do something else, and I'm not
| > sure howto?
| >
| > --
| >
| >
| > Kind Regards
| > Rudi Ahlers
| > +27 (82) 926 1689
| >
| > Greater love has no one than this, that he lay down his life for his
| friends
| > (John 15:13).
| >
| >
|
|
Jul 19 '05 #4
If Not IsNumeric(industry) Then

'---- Do Stuff

End If

Bob Lehmann

"Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
news:cd**********@ctb-nnrp2.saix.net...
Ok, one more question, how do I use this, if I want to checkif it's not an
integer.

I want to check two things, like so:

if company_count = 0 and Is(not?)Numeric(industry) then
// stuff here
end if

i.e. If company_count = 0, and industry is not an integer?
--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends (John 15:13).
"Steven Burn" <pv*@noyb.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
| If IsNumeric(String_To_Check) Then
| '// True
| '// Do something
| Else
| '// False
| '// Do something else
| End If
|
| --
|
| Regards
|
| Steven Burn
| Ur I.T. Mate Group
| www.it-mate.co.uk
|
| Keeping it FREE!
|
|
| "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| news:cd**********@ctb-nnrp2.saix.net...
| > Sorry for the dumb question, but what is the function in ASP to see if
an
| > object / string is an integer?
| >
| > I want to check the contents of a form, and if it's an integer, i.e a
| > number, do something, else if it's a word do something else, and I'm not | > sure howto?
| >
| > --
| >
| >
| > Kind Regards
| > Rudi Ahlers
| > +27 (82) 926 1689
| >
| > Greater love has no one than this, that he lay down his life for his
| friends
| > (John 15:13).
| >
| >
|
|

Jul 19 '05 #5
Actually, these are VbScript commands.

VbScript documentation..
http://msdn.microsoft.com/library/de...riVBScript.asp

JScript documentation...
http://msdn.microsoft.com/library/de...oriJScript.asp

Bob Lehmann

"Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
news:cd**********@ctb-nnrp2.saix.net...
Aha, thanx very much :)

btw, is there a manual / website with all the classis ASP commands /
functions / etc?

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends (John 15:13).
"Steven Burn" <pv*@noyb.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
| If IsNumeric(String_To_Check) Then
| '// True
| '// Do something
| Else
| '// False
| '// Do something else
| End If
|
| --
|
| Regards
|
| Steven Burn
| Ur I.T. Mate Group
| www.it-mate.co.uk
|
| Keeping it FREE!
|
|
| "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| news:cd**********@ctb-nnrp2.saix.net...
| > Sorry for the dumb question, but what is the function in ASP to see if
an
| > object / string is an integer?
| >
| > I want to check the contents of a form, and if it's an integer, i.e a
| > number, do something, else if it's a word do something else, and I'm not | > sure howto?
| >
| > --
| >
| >
| > Kind Regards
| > Rudi Ahlers
| > +27 (82) 926 1689
| >
| > Greater love has no one than this, that he lay down his life for his
| friends
| > (John 15:13).
| >
| >
|
|

Jul 19 '05 #6
Thanx :)

--
Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:uf**************@TK2MSFTNGP09.phx.gbl...
| If Not IsNumeric(industry) Then
|
| '---- Do Stuff
|
| End If
|
| Bob Lehmann
|
| "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| news:cd**********@ctb-nnrp2.saix.net...
| > Ok, one more question, how do I use this, if I want to checkif it's not
an
| > integer.
| >
| > I want to check two things, like so:
| >
| > if company_count = 0 and Is(not?)Numeric(industry) then
| > // stuff here
| > end if
| >
| > i.e. If company_count = 0, and industry is not an integer?
| > --
| >
| >
| > Kind Regards
| > Rudi Ahlers
| > +27 (82) 926 1689
| >
| > Greater love has no one than this, that he lay down his life for his
| friends
| > (John 15:13).
| > "Steven Burn" <pv*@noyb.com> wrote in message
| > news:e1**************@TK2MSFTNGP09.phx.gbl...
| > | If IsNumeric(String_To_Check) Then
| > | '// True
| > | '// Do something
| > | Else
| > | '// False
| > | '// Do something else
| > | End If
| > |
| > | --
| > |
| > | Regards
| > |
| > | Steven Burn
| > | Ur I.T. Mate Group
| > | www.it-mate.co.uk
| > |
| > | Keeping it FREE!
| > |
| > |
| > | "Lord Merlin" <SP*************@bonzai.org.za_SPAM> wrote in message
| > | news:cd**********@ctb-nnrp2.saix.net...
| > | > Sorry for the dumb question, but what is the function in ASP to see
if
| > an
| > | > object / string is an integer?
| > | >
| > | > I want to check the contents of a form, and if it's an integer, i.e
a
| > | > number, do something, else if it's a word do something else, and I'm
| not
| > | > sure howto?
| > | >
| > | > --
| > | >
| > | >
| > | > Kind Regards
| > | > Rudi Ahlers
| > | > +27 (82) 926 1689
| > | >
| > | > Greater love has no one than this, that he lay down his life for his
| > | friends
| > | > (John 15:13).
| > | >
| > | >
| > |
| > |
| >
| >
|
|
Jul 19 '05 #7
On Thu, 22 Jul 2004 00:01:19 +0200, "Lord Merlin"
<SP*************@bonzai.org.za_SPAM> wrote:
Aha, thanx very much :)

btw, is there a manual / website with all the classis ASP commands /
functions / etc?


I personally like DevGuru:

http://www.devguru.com/Technologies/...ipt_intro.html

Jeff
Jul 19 '05 #8
Lord Merlin wrote:
Sorry for the dumb question, but what is the function in ASP to see
if an object / string is an integer?

I want to check the contents of a form, and if it's an integer, i.e a
number, do something, else if it's a word do something else, and I'm
not sure howto?


Everone has been recommending IsNumeric(), but that function is flawed. What
do you guess will be returned by:

Response.Write IsNumeric("1e2")

Try it, I'll wait.
Surprised? Try "1d2".

The explanation is that e and d are exponent indicators. Try CDbl("1d2") and
see what you get ....

100, right? "d" and "e" aren't the only characters that can cross you up.
Depending on the locale, some characters can be used for currency symbols
and thus will also be passed by IsNumeric(), which only verifies that a
string can be converted to at least one of the many numeric subtypes
(including currency, double, single and integer).

The real solution is to use a regular expression to verify that the string
contains only the characters 0-9 (you could use on error resume next and
CInt(), checking for an error on the following line, but it's silly to raise
an error for this purpose).

I just got called away, so somebody else is going to have to show you the
reg exp to use for this task. Chris Hohmann, are you out there? :-)

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #9
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
The real solution is to use a regular expression to verify that the string
contains only the characters 0-9 (you could use on error resume next and
CInt(), checking for an error on the following line, but it's silly to raise an error for this purpose).

I just got called away, so somebody else is going to have to show you the
reg exp to use for this task. Chris Hohmann, are you out there? :-)


Positive Integer Without Separator:
^\d{1,5}$

Positive Integer With Separator:
^(\d{1,2},\d{3}|\d{1,3}$

Positive/Negative Without Separator:
^-?\d{1,5}$

Positive/Negative With Separator
^-?(\d{1,2},\d{3}|\d{1,3})$
You may need to adjust the above if your locale uses something other than
comma as the thousands separator. Also, you'll want to check for integer
overflow errors.
Jul 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by CSharp | last post: by
1 post views Thread by Boni | last post: by
2 posts views Thread by Helmut Jarausch | last post: by
4 posts views Thread by Mark Berry | last post: by
5 posts views Thread by futileissue | last post: by
reply views Thread by Edwin.Madari | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.