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

Variable smaller than question.

Hi,

Can somebody tell me why when I run this code i get this result?

<%
If Available < Requested then

Response.Write "Available = "&Available&"<BR>"
Response.Write "Requested = "&Requested

Else

blah blah blah

End If
%>

Result:

Available = 5
Requested = 2

It's clear that Available is not smaller than Requested so why is it
response.writing instead of doing blah blah blah?

Is my syntax horribly wrong or something?

Help Appreciated. Thanks.
Jul 19 '05 #1
3 1292
"Miguel Orrego" wrote:
: <%
: If Available < Requested then
:
: Response.Write "Available = "&Available&"<BR>"
: Response.Write "Requested = "&Requested
:
: Else
:
: blah blah blah
:
: End If
: %>
:
: Result:
:
: Available = 5
: Requested = 2
:
: It's clear that Available is not smaller than Requested so why is it
: response.writing instead of doing blah blah blah?
:
: Is my syntax horribly wrong or something?

Miguel...

Put this right under <%@ LANGUAGE=VBScript %>
<% Option Explicit %>

If you typed your code in here, perhaps in your code there is a typo for
Available.
Option Explicit requires that you (Dim)ension all variables so if you have a
typo, it will tell you.
Also, put a space on either side of & so you do not have a problem with hex
values &h and so it is easier to read.

<%@ LANGUAGE=VBScript %>
<%
Option Explicit

Dim Available, Requested
Available = 5
Requested = 2

If Available < Requested then
Response.Write "Available = " & Available & "<BR>"
Response.Write "Requested = " & Requested
Else
'blah blah blah
End If
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #2
More likely that the < operator is comparing string to string.

So try this:

<%
If IsNumeric(Available) and IsNumeric(Requested) Then
If CDbl(Available) < CDbl(Requested) then
Response.Write "Available = " & Available & "<BR>"
Response.Write "Requested = " & Requested
Else
'blah blah blah
End If
Else
Response.Write "One or more of the variables are *not* numeric"
End if
%>

Also remember to use spaces around the ampersand (concatenation) operator.

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi,

Can somebody tell me why when I run this code i get this result?

<%
If Available < Requested then

Response.Write "Available = "&Available&"<BR>"
Response.Write "Requested = "&Requested

Else

blah blah blah

End If
%>

Result:

Available = 5
Requested = 2

It's clear that Available is not smaller than Requested so why is it
response.writing instead of doing blah blah blah?

Is my syntax horribly wrong or something?

Help Appreciated. Thanks.

Jul 19 '05 #3
Yep, that was the one.

Thanks Chris!
"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
More likely that the < operator is comparing string to string.

So try this:

<%
If IsNumeric(Available) and IsNumeric(Requested) Then
If CDbl(Available) < CDbl(Requested) then
Response.Write "Available = " & Available & "<BR>"
Response.Write "Requested = " & Requested
Else
'blah blah blah
End If
Else
Response.Write "One or more of the variables are *not* numeric"
End if
%>

Also remember to use spaces around the ampersand (concatenation) operator.

"Miguel Orrego" <mi****@stressedmonkey.net-nospam> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi,

Can somebody tell me why when I run this code i get this result?

<%
If Available < Requested then

Response.Write "Available = "&Available&"<BR>"
Response.Write "Requested = "&Requested

Else

blah blah blah

End If
%>

Result:

Available = 5
Requested = 2

It's clear that Available is not smaller than Requested so why is it
response.writing instead of doing blah blah blah?

Is my syntax horribly wrong or something?

Help Appreciated. Thanks.

Jul 19 '05 #4

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

Similar topics

14
by: Gregory | last post by:
Hello, I'm trying to do the above in order to process an image and return the result to an html image control. It fails and my key suspects are either the variable that I'm passing in -...
0
by: AJ Shankar | last post by:
Hi, In the C API, is there any way to execute a query, store all the results, and somehow find the maximum realized width for each of the fields before fetching each row? Otherwise there is no...
7
by: YGeek | last post by:
Is there any difference between declaring a variable at the top of a method versus in the code of the method? Is there a performance impact for either choice? What about if the method will return...
24
by: LP | last post by:
After a code review one coworker insisted that global are very dangerous. He didn't really give any solid reasons other than, "performance penalties", "hard to maintain", and "dangerous". I think...
22
by: petermichaux | last post by:
Hi, I'm curious about server load and download time if I use one big javascript file or break it into several smaller ones. Which is better? (Please think of this as the first time the scripts...
6
by: krisworld | last post by:
hi is this possible to create a variable of 4 bit in C language. An Example shall help me a lot. Thanks Kris...
13
by: lak | last post by:
I want to know what is the variable length in c. I K&R they stated that atleast 31 character. But I give 1 lakhs length to a variable, but my compiler doesn't say any error. It accepts it.Then...
5
by: Guenther Sohler | last post by:
Dear Group, In the past I read something, that it is possible to print out php variables in html very fast with a simple symtax. Today I came back to php documentation, but I cannot find it...
8
by: Gerhard Fiedler | last post by:
Hello, I'm not sure whether this is a problem or not, or how to determine whether it is one. Say memory access (read and write) happens in 64-bit chunks, and I'm looking at 32-bit variables....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.