473,394 Members | 1,701 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,394 software developers and data experts.

greater then / less then

Why can I not compare 2 numbers?

what i have is this:

dim T as string = "101"
dim W as string = "99"

if T > W then
response.write("T is greater")
end if

if the numbers look like this is doesn't compare them. if they are both over
a 100 it works, and if they are both under 100 it works but if they are like
above it fails, how can i get this working?
I also tired the "classic asp" way and same results
Nov 18 '05 #1
2 1266
Do you want to compare them as strings or as numbers?
If you want to evaluate them as numbers (as I suspect you do) then try this
code instead to convert them to integers before comparing:

If CInt(T) > CInt(W) Then...

Of course it might be better to declare them as integers in the first place
instead of strings.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Why can I not compare 2 numbers?

what i have is this:

dim T as string = "101"
dim W as string = "99"

if T > W then
response.write("T is greater")
end if

if the numbers look like this is doesn't compare them. if they are both
over
a 100 it works, and if they are both under 100 it works but if they are
like
above it fails, how can i get this working?
I also tired the "classic asp" way and same results

Nov 18 '05 #2
You can compare 2 numbers. You're trying to compare 2 strings. A number is
not a string. A string is not a number.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Why can I not compare 2 numbers?

what i have is this:

dim T as string = "101"
dim W as string = "99"

if T > W then
response.write("T is greater")
end if

if the numbers look like this is doesn't compare them. if they are both over a 100 it works, and if they are both under 100 it works but if they are like above it fails, how can i get this working?
I also tired the "classic asp" way and same results

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hebar Tiltwobler | last post by:
I need to figure out if the current date (passed in as a string) is equal to or greater then a field in my database in the format of- M/D/YYYY AND if the date is less then another field in my...
1
by: trinity | last post by:
Hello all, First, I am grateful for this forum and all comments that will be posted. I am designing a database that compiles data from sewage treatment plants. Mostly the data is numeric. ...
3
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
7
by: BobRoyAce | last post by:
Let's say I have a text box on a page in which a user is to enter a monetary amount and that I want to ensure that the user enters a value greater than or equal to a certain value that will be...
2
by: AboutJAV | last post by:
Hi, In my code, I accept very long string, which may be greater than 2046 bytes. String can not exceed this limit. What else can I use to store these very long string? Thanks,
14
by: MLH | last post by:
After entering a date (earlier than today's date) into a textbox control though, I'm stumped as to why VBA thinks date I enter into the control is greater than Now - when they are CLEARLY less than...
77
by: borophyll | last post by:
As I read it, C99 states that a byte is an: "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment" (3.6) and that a byte...
6
by: Acrobatic | last post by:
Hello, I know this will be an easy fix--but as of now I'm banging my head against the wall. I need a fresh perspective from the group to see what my problem is: This is a simple accounting...
5
by: leemarquis | last post by:
Is there a way to determine the correct cellindex of cells in a table when some of the cells have rowspans greater than 1. Perhaps correct is the wrong word - but when I have a cell with a rowspan...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.