473,545 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Number comparison error

PW

I'm trying to interrogate an incoming value from a previous ASP like this
....

myCurrentQty = request.queryst ring("txtBCQty" & myRecordCounter )

It returns a "2" as expected.

But if I try to compare its value to another number, like this ...

if myCurrentQty > 0 then

.... I get this error ...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'myCurrentQty'
rep_barcode2.as p, line 57

If I try to convert it to a number, like this ...

if Cint(myCurrentQ ty) > 0 then

I get another error ...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'Cint'
rep_barcode2.as p, line 57

Not quite sure where I'm going wrong here.

Any help appreciated.

Thanks,
PW

Jul 19 '05 #1
7 3749
PW wrote:
I'm trying to interrogate an incoming value from a previous ASP like
this ...

myCurrentQty = request.queryst ring("txtBCQty" & myRecordCounter )

It returns a "2" as expected.

But if I try to compare its value to another number, like this ...

if myCurrentQty > 0 then

... I get this error ...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'myCurrentQty'
rep_barcode2.as p, line 57

If I try to convert it to a number, like this ...

if Cint(myCurrentQ ty) > 0 then

I get another error ...

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'Cint'
rep_barcode2.as p, line 57


Hmmm - show us the result of:

response.write "myCurrentQ ty contains """ & myCurrentQty & """"

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
PW


"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:OE******** ******@TK2MSFTN GP09.phx.gbl...
Hmmm - show us the result of:
response.write "myCurrentQ ty contains """ & myCurrentQty & """"

I'll go one further and show you the variable type as well ...

myCurrentQty = request.queryst ring("txtBCQty" & myRecordCounter )
response.write "myCurrentQ ty contains """ & myCurrentQty & """"
if isnumeric("myCu rrentQty") then
response.write "number"
else
response.write "char"
end if
response.end
Results are ...

myCurrentQty contains "2"
char
Jul 19 '05 #3
myCurrentQty = Trim(myCurrentQ ty )
If IsNumeric(myCur rentQty ) Then
If CInt(myCurrentQ ty ) > 0 Then

End If
End If

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #4
PW

"dlbjr" <dl***@imlost.c om> wrote in message
news:OO******** ******@TK2MSFTN GP11.phx.gbl...
myCurrentQty = Trim(myCurrentQ ty )
If IsNumeric(myCur rentQty ) Then
If CInt(myCurrentQ ty ) > 0 Then

End If
End If

I don't think that will help. I know that myCurrentQty contains a number,
the problem is that its a variable type of char and won't convert to a
variable type of number.

Jul 19 '05 #5
"PW" wrote in message news:OK******** *****@TK2MSFTNG P10.phx.gbl...
:
: "dlbjr" <dl***@imlost.c om> wrote in message
: news:OO******** ******@TK2MSFTN GP11.phx.gbl...
: > myCurrentQty = Trim(myCurrentQ ty )
: > If IsNumeric(myCur rentQty ) Then
: > If CInt(myCurrentQ ty ) > 0 Then
: >
: > End If
: > End If
:
: I don't think that will help. I know that myCurrentQty contains a number,
: the problem is that its a variable type of char and won't convert to a
: variable type of number.

myCurrentQty = Int(Trim(Reques t.QueryString(" txtBCQty"))) &
Int(myRecordCou nter)
Response.Write( "myCurrentQ ty contains " & myCurrentQty & " and is data type
" & typename(myCurr entQty) & ".")
if myCurrentQty > 0 Then
' do something
else
' do nothing
Response.End
end if

--
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 #6
PW

"Roland Hall" <nobody@nowhere > wrote in message
news:Ow******** *****@tk2msftng p13.phx.gbl...
myCurrentQty = Int(Trim(Reques t.QueryString(" txtBCQty"))) &
Int(myRecordCou nter)
Response.Write( "myCurrentQ ty contains " & myCurrentQty & " and is data type " & typename(myCurr entQty) & ".")
if myCurrentQty > 0 Then
' do something
else
' do nothing
Response.End
end if

Now this is wierd !! I ran my code, and I got the error. I ran Rolands
code, and no error. WHAT! Do it again. Run my code, get an error. Run
Rolands code, no error! HUH!?!?

I then realised that the error was not occurring on the first iteration of
the loop, but on the 3rd, in which that label had not been given a quantity
of labels to print, hence the variable was empty, and the error occurs. I
fixed it by adding this little code snippet ...

if myCurrentQty = "" then
myCurrentQty = 0
end if
Thanks for your help guys,
PW

Jul 19 '05 #7
"PW" wrote in message news:uu******** ******@TK2MSFTN GP11.phx.gbl...
:
: "Roland Hall" <nobody@nowhere > wrote in message
: news:Ow******** *****@tk2msftng p13.phx.gbl...
: > myCurrentQty = Int(Trim(Reques t.QueryString(" txtBCQty"))) &
: > Int(myRecordCou nter)
: > Response.Write( "myCurrentQ ty contains " & myCurrentQty & " and is data
: type
: > " & typename(myCurr entQty) & ".")
: > if myCurrentQty > 0 Then
: > ' do something
: > else
: > ' do nothing
: > Response.End
: > end if
:
:
: Now this is wierd !! I ran my code, and I got the error. I ran Rolands
: code, and no error. WHAT! Do it again. Run my code, get an error. Run
: Rolands code, no error! HUH!?!?
:
: I then realised that the error was not occurring on the first iteration of
: the loop, but on the 3rd, in which that label had not been given a
quantity
: of labels to print, hence the variable was empty, and the error occurs. I
: fixed it by adding this little code snippet ...
:
: if myCurrentQty = "" then
: myCurrentQty = 0
: end if

So, persistance actually does pay off.

: Thanks for your help guys,

Anytime but you did it.
Jul 19 '05 #8

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

Similar topics

3
2996
by: Stephen Poley | last post by:
Could some kind soul explain the errors and warnings that the W3C CSS validator generates for page: http://www.atlis.nl/testsite/nl/ Results at: http://tinyurl.com/5pxqx The error "Invalid number : borderParse Error - " may be due to something I've done, but I'm blowed if I can see what. While the warning "property display doesn't...
6
6774
by: David Cook | last post by:
The html file below gets intermittent errors 'error on page' ('number expected') when clicking on column-headings to sort. Yet, this same file works flawlessly in other browsers (i.e. Opera, Mozilla, Netscape, etc.). Can anyone suggest a fix/workaround? Cheers...
7
7231
by: astro | last post by:
Anyone have suggestions on where to troubleshoot this error? Background: -Access 2k v. 9.0.6926 sp3 - front and backend on production server (wiindows 2k) -accessed via Citrix -front-end is mde, backend is mdb -only occurs on the production server -only occurs with mde verson - i've tested the problem with the mdb version of the...
3
1900
by: Chandu | last post by:
Hi, I am working on awk programming which is similar to C programming and have got a doubt about time function returning a float value. Ex: 01:01:30 should return 61.5 when i have tried my way i am not able to get the seconds value (30/60=0.5) So can anyone give me ideas, throught which i can do similar coding in AWK programming. Secondly...
9
2820
by: kangaroo | last post by:
Hi guys, when we run a stored proc and it results into an unhandled error, the error message returned by db2 udb does not contain a line number that caused an error. This makes it pretty difficult to debug those procs. Line number have always been there in Oracle messages. When I Googled on this, I saw some people showing DB2 Stored Proc...
2
1146
by: John | last post by:
Hi I am getting the 'Operator is not valid for type 'DBNull' and string "".' error on the following line; If (mydatatable.Rows.Item(I).Item("Forenames") Is System.DBNull.Value) Then ' 'I' is the loop variable from 0 To mydatatable.Rows.Count - 1. Any ideas on what is the reason for this error?
1
2286
by: comp.lang.php | last post by:
I have written several applications that have very specific functionality that is version-dependent, furthermore, requirements dictate my apps span multiple versions of PHP. I have written a function that detects which version of PHP and ultimately converts it into integer form, however, I am foreseeing a problem in doing this which I will...
1
1557
by: bjjnova | last post by:
I have the following string comparison that is throwing an error I cannot find ( I will include my attempts to trace the error) In the line following the asterisks, written as I have below, a true is always returned and the printed msg appears that the 2 variables are not equal. This happens even when the print statement writes out,...
2
1651
by: chazzy69 | last post by:
Hi, im just trying to compare a character(char) to a set list of characters (e.g. "a", "b", etc). first i read in the value- (i have tried this two ways) scanf("%c", &var_name); //also tried this and yes i know the difference scanf("%s", &var_name); When i printf this value -
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5326
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.