473,486 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Create 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.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 3744
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2990
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...
6
6773
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,...
7
7227
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...
3
1892
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...
9
2813
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...
2
1145
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...
1
2282
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...
1
1553
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...
2
1648
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...
0
7099
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
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...
1
6842
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...
0
7319
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
5430
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,...
1
4864
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.