Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Number comparison error

Reply
Thread Tools

Number comparison error

 
 
PW
Guest
Posts: n/a
 
      05-23-2004

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



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-23-2004
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"


 
Reply With Quote
 
 
 
 
PW
Guest
Posts: n/a
 
      05-23-2004


"Bob Barrows [MVP]" <> wrote in message
news:...
> 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


 
Reply With Quote
 
dlbjr
Guest
Posts: n/a
 
      05-23-2004
myCurrentQty = Trim(myCurrentQty )
If IsNumeric(myCurrentQty ) Then
If CInt(myCurrentQty ) > 0 Then

End If
End If

-dlbjr

Discerning resolutions for the alms


 
Reply With Quote
 
PW
Guest
Posts: n/a
 
      05-23-2004

"dlbjr" <> wrote in message
news:...
> 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.



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      05-23-2004
"PW" wrote in message news:...
:
: "dlbjr" <> wrote in message
: news:...
: > 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


 
Reply With Quote
 
PW
Guest
Posts: n/a
 
      05-24-2004

"Roland Hall" <nobody@nowhere> wrote in message
news:...
> 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



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      05-25-2004
"PW" wrote in message news:...
:
: "Roland Hall" <nobody@nowhere> wrote in message
: news:...
: > 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison of 2 files and generating the output based on comparison Deepu Perl Misc 1 02-07-2011 03:09 PM
Price Comparison Service. Best Deal. Special Coupon atBest-Price-Comparison.com rapee Digital Photography 0 03-14-2008 06:46 AM
OT: Number Nine, Number Nine, Number Nine FrisbeeŽ MCSE 37 09-26-2005 04:06 PM
Regarding Time conversion, secondly number comparison Chandu C Programming 3 09-19-2005 08:32 PM
Version Number Comparison Function Keith Python 14 03-29-2005 09:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57