469,356 Members | 1,994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Number comparison error

PW

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

myCurrentQty = request.querystring("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.asp, line 57

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

if Cint(myCurrentQty) > 0 then

I get another error ...

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

Not quite sure where I'm going wrong here.

Any help appreciated.

Thanks,
PW

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

myCurrentQty = request.querystring("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.asp, line 57

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

if Cint(myCurrentQty) > 0 then

I get another error ...

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


Hmmm - show us the result of:

response.write "myCurrentQty 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******@NOyahoo.SPAMcom> wrote in message
news:OE**************@TK2MSFTNGP09.phx.gbl...
Hmmm - show us the result of:
response.write "myCurrentQty contains """ & myCurrentQty & """"

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

myCurrentQty = request.querystring("txtBCQty" & myRecordCounter)
response.write "myCurrentQty contains """ & myCurrentQty & """"
if isnumeric("myCurrentQty") then
response.write "number"
else
response.write "char"
end if
response.end
Results are ...

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

End If
End If

-dlbjr

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

"dlbjr" <dl***@imlost.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
myCurrentQty = Trim(myCurrentQty )
If IsNumeric(myCurrentQty ) Then
If CInt(myCurrentQty ) > 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*************@TK2MSFTNGP10.phx.gbl...
:
: "dlbjr" <dl***@imlost.com> wrote in message
: news:OO**************@TK2MSFTNGP11.phx.gbl...
: > myCurrentQty = Trim(myCurrentQty )
: > If IsNumeric(myCurrentQty ) Then
: > If CInt(myCurrentQty ) > 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(Request.QueryString("txtBCQty"))) &
Int(myRecordCounter)
Response.Write("myCurrentQty contains " & myCurrentQty & " and is data type
" & typename(myCurrentQty) & ".")
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*************@tk2msftngp13.phx.gbl...
myCurrentQty = Int(Trim(Request.QueryString("txtBCQty"))) &
Int(myRecordCounter)
Response.Write("myCurrentQty contains " & myCurrentQty & " and is data type " & typename(myCurrentQty) & ".")
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**************@TK2MSFTNGP11.phx.gbl...
:
: "Roland Hall" <nobody@nowhere> wrote in message
: news:Ow*************@tk2msftngp13.phx.gbl...
: > myCurrentQty = Int(Trim(Request.QueryString("txtBCQty"))) &
: > Int(myRecordCounter)
: > Response.Write("myCurrentQty contains " & myCurrentQty & " and is data
: type
: > " & typename(myCurrentQty) & ".")
: > 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by David Cook | last post: by
2 posts views Thread by John | last post: by
1 post views Thread by comp.lang.php | last post: by
1 post views Thread by bjjnova | last post: by
2 posts views Thread by chazzy69 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.