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

help with numbers !

Hi,

I'm just trying to work out the postage costs for a shopping cart and for
some reason (possibly me being silly) i can't get the following to work :

Dim strWeight3, strWeight4
strWeight3 = "950"
If strWeight3<="1000" Then strWeight4="3.32" Else strWeight4="7.50"
Response.Write(strWeight3 & "&nbsp;/&nbsp;")
Response.Write(strWeight4)
So the weight's in Grammes, If it's over 1000g then the price is 7.50
otherwise it's 3.32.
The problem is this will only return the figure 7.50 for some reason
.................

Any pointers appreciated.

Thanks
Jul 19 '05 #1
2 2378
John,
Dim strWeight3, strWeight4
strWeight3 = "950"
If strWeight3<="1000" Then strWeight4="3.32" Else strWeight4="7.50"
Response.Write(strWeight3 & "&nbsp;/&nbsp;")
Response.Write(strWeight4)


You are comparing two "strings" and so, "1000" is less that "950"

Brian Staff

Jul 19 '05 #2
John Smith wrote on 30 jun 2003 in microsoft.public.inetserver.asp.general:
Just out of interest, i know that it won't work correctly if it was :

If intWeight3 <"1000" Then....

But why is this ?


comparing two strings alphabetically:

each character is compared by its ascii value,
and strings from left to right,
till there is a difference:

"9" < "A"

"A" < "a"

"8" > "1"

"abc1" < "abc2"

"adc1" > "abc1"

"bbb" > "abbb"

"800" > "1000"
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3

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

Similar topics

28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
4
by: Samantha | last post by:
I am new to Python and am attempting to write a routine that will display a five game selection for a power ball drawing. I think I have the random drawing set to work ok, but I want to have the...
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
3
by: ali | last post by:
i have to creat a programme that Accept any collection of real numbers up to 25.Calculate and display the average then Find and display the median--the number closest to the middle. i did i wrote...
2
by: mcpacs™ | last post by:
hey guys!! arrays really makes me confused. will you help me about this?: create a program that that accepts ten positive integers from the users. The program will group and sort all even numbers...
4
by: UMstudent | last post by:
I'm working on this program for class where I have to an amount of numbers that are randomly picked from 0 - 50. So what I have done is say there are 20 slots in my array so I'm trying to generator...
1
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
1
by: vekka | last post by:
Hi! Programming language: C I wondered if any of you are able to see what is wrong with my code. What I want to do is to find the union of a set of numbers. I use a singly linked list. and my union...
1
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.