Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:20 PM
Lord Merlin
Guest
 
Posts: n/a
Default 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).


  #2  
Old July 19th, 2005, 02:20 PM
Steven Burn
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
news:cdmo3m$bdk$1@ctb-nnrp2.saix.net...[color=blue]
> 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[/color]
friends[color=blue]
> (John 15:13).
>
>[/color]


  #3  
Old July 19th, 2005, 02:20 PM
Lord Merlin
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

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" <pvt@noyb.com> wrote in message
news:e1iac12bEHA.1732@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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
| news:cdmo3m$bdk$1@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).
| >
| >
|
|


  #4  
Old July 19th, 2005, 02:20 PM
Lord Merlin
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

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" <pvt@noyb.com> wrote in message
news:e1iac12bEHA.1732@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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
| news:cdmo3m$bdk$1@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).
| >
| >
|
|


  #5  
Old July 19th, 2005, 02:20 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

If Not IsNumeric(industry) Then

'---- Do Stuff

End If

Bob Lehmann

"Lord Merlin" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
news:cdmp8g$fme$1@ctb-nnrp2.saix.net...[color=blue]
> 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[/color]
friends[color=blue]
> (John 15:13).
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:e1iac12bEHA.1732@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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
> | news:cdmo3m$bdk$1@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[/color]
not[color=blue]
> | > 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).
> | >
> | >
> |
> |
>
>[/color]


  #6  
Old July 19th, 2005, 02:20 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
news:cdmp3c$f5g$1@ctb-nnrp2.saix.net...[color=blue]
> 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[/color]
friends[color=blue]
> (John 15:13).
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:e1iac12bEHA.1732@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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
> | news:cdmo3m$bdk$1@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[/color]
not[color=blue]
> | > 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).
> | >
> | >
> |
> |
>
>[/color]


  #7  
Old July 19th, 2005, 02:20 PM
Lord Merlin
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

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" <nospam@dontbotherme.zzz> wrote in message
news:ufdeEJ3bEHA.1152@TK2MSFTNGP09.phx.gbl...
| If Not IsNumeric(industry) Then
|
| '---- Do Stuff
|
| End If
|
| Bob Lehmann
|
| "Lord Merlin" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
| news:cdmp8g$fme$1@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" <pvt@noyb.com> wrote in message
| > news:e1iac12bEHA.1732@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" <SPAM_lordmerlin@bonzai.org.za_SPAM> wrote in message
| > | news:cdmo3m$bdk$1@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).
| > | >
| > | >
| > |
| > |
| >
| >
|
|


  #8  
Old July 19th, 2005, 02:20 PM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

On Thu, 22 Jul 2004 00:01:19 +0200, "Lord Merlin"
<SPAM_lordmerlin@bonzai.org.za_SPAM> wrote:
[color=blue]
>Aha, thanx very much :)
>
>btw, is there a manual / website with all the classis ASP commands /
>functions / etc?[/color]

I personally like DevGuru:

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

Jeff
  #9  
Old July 19th, 2005, 02:20 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

Lord Merlin wrote:[color=blue]
> 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?[/color]

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.


  #10  
Old July 19th, 2005, 02:21 PM
Chris Hohmann
Guest
 
Posts: n/a
Default Re: can ASP check if an object is an integer?

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23jkskQBcEHA.1248@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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[/color]
raise[color=blue]
> 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? :-)[/color]

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.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles