473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 38531
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CSharp | last post by:
Is it possible to find if lower 1st bit and 2nd bit in an 32-bit integer is set using regular expression in C# Example 1. Input Strings - 0, 1, 2 Result - Fai 2. Input Strings - 3, 7, ...
1
by: Boni | last post by:
Dear all, is it possible to switch somehow to the mode where integer.maxvalue+1 will return integer.minvalue instead of throwing the exception? Thanks, Boni
2
by: Helmut Jarausch | last post by:
Hi, sorry, this seems to be a FAQ but I couldn't find anything I need to check if an object is a compiled regular expression Say import re RX= re.compile('^something') how to test
5
by: YardDancer | last post by:
Hi all I don't want to use the the Cint() or CDec() or other VB.Net Functions and I dont want to restrict keystrokes in the textbox. I am also using the "strict type semantic" settings that...
4
by: Mark Berry | last post by:
Hi, I'm working on my "last resort" error block for a web application. If the error occurs after a Request has been made, I want to show the URL. If the Request object is not available, I'll...
5
by: futileissue | last post by:
Beginner, so please bare with me. I'm not sure what to call what it is I'm looking for. If I have an object class, let's call it "Creature": class Creature: def __init__(self, status):...
0
by: Edwin.Madari | last post by:
updated creature running in its own thread will get you started. try it foryourself, change sleep times per your need. import os, sys, threading, time class Creature: def __init__(self,...
7
by: ismailc | last post by:
Good day, I thought i had this sorted but it does not seem to check if the object is undefined / not created. I'm trying to check if object is undefined & i tried a few methos but no luck...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.