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

Percentage Calculation question....

Hi,

I have the following calculation I am trying to work out ..... Not sure
how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error
What is the correct way of writing this calculation ?

Thanks

David

Oct 11 '06 #1
6 3436
"I just get an error."

What's the error?! What's the value of oDict(oKey)?

Ray at work
"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,

I have the following calculation I am trying to work out ..... Not sure
how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error
What is the correct way of writing this calculation ?

Thanks

David

Oct 11 '06 #2
Hi Ray,

It is a calculated integer. A sum of a calculation

David

-------------------------------------------------------
Ray Costanzo [MVP] wrote:
"I just get an error."

What's the error?! What's the value of oDict(oKey)?

Ray at work
"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,

I have the following calculation I am trying to work out ..... Not sure
how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error
What is the correct way of writing this calculation ?

Thanks

David
---------------------------------------------

Oct 11 '06 #3
>>>

Microsoft VBScript runtime error '800a000d'

Type mismatch

/L&R/Metal/complete_orderbook_view.asp, line 120
David wrote:
Hi Ray,

It is a calculated integer. A sum of a calculation

David

-------------------------------------------------------
Ray Costanzo [MVP] wrote:
"I just get an error."

What's the error?! What's the value of oDict(oKey)?

Ray at work
"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,
>
I have the following calculation I am trying to work out ..... Not sure
how ?
>
Variable 1 = minstock
Variable 2 = oDict(oKey)
>
I need to test if my variable 'minstock' <= 40% of oDict(oKey)
>
I've tried
>
IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if
>
I just get an error
>
>
What is the correct way of writing this calculation ?
>
Thanks
>
David
>

---------------------------------------------
Oct 11 '06 #4
Do a Response.Write TypeName(oDict(oKey)) to check. You should also check
the datatype of minstock.

--
Mike Brind
"David" <da*********@scene-double.co.ukwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
>>>>

Microsoft VBScript runtime error '800a000d'

Type mismatch

/L&R/Metal/complete_orderbook_view.asp, line 120
David wrote:
>Hi Ray,

It is a calculated integer. A sum of a calculation

David

-------------------------------------------------------
Ray Costanzo [MVP] wrote:
"I just get an error."

What's the error?! What's the value of oDict(oKey)?

Ray at work
"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,

I have the following calculation I am trying to work out ..... Not
sure
how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error
What is the correct way of writing this calculation ?

Thanks

David

---------------------------------------------

Oct 11 '06 #5
David wrote:
Hi,

I have the following calculation I am trying to work out ..... Not
sure how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error
What error?
>
What is the correct way of writing this calculation ?
It looks correct to me.
Give us some actual data to look at, i.e., provide us with a repro
script that we can run to reproduce your symptoms. We don't want to see
your entire page -- we don't even need to see your actual data. Just
provide a small repro script that uses data that reproduces the
symptoms. Something like this:

<%
dim oKey, oDict, minstock
minstock=20
set oDict=createobject("scripting.dictionary")
oKey="test"
oDict.Add oKey, 100
IF minstock <= oDict(oKey)*0.4 then
Response.Write "Low Stock"
Else
Response.Write "Stock OK"
End If
%>

This works fine for me, by the way.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 11 '06 #6

Bob Barrows [MVP] wrote:
David wrote:
Hi,

I have the following calculation I am trying to work out ..... Not
sure how ?

Variable 1 = minstock
Variable 2 = oDict(oKey)

I need to test if my variable 'minstock' <= 40% of oDict(oKey)

I've tried

IF minstock <= oDict(oKey)*0.4 then
swarn = "Low Stock"
else
swarn = "&nbsp;"
end if

I just get an error

What error?

What is the correct way of writing this calculation ?

It looks correct to me.
Give us some actual data to look at, i.e., provide us with a repro
script that we can run to reproduce your symptoms. We don't want to see
your entire page -- we don't even need to see your actual data. Just
provide a small repro script that uses data that reproduces the
symptoms. Something like this:

<%
dim oKey, oDict, minstock
minstock=20
set oDict=createobject("scripting.dictionary")
oKey="test"
oDict.Add oKey, 100
IF minstock <= oDict(oKey)*0.4 then
Response.Write "Low Stock"
Else
Response.Write "Stock OK"
End If
%>

This works fine for me, by the way.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

------------------------------

Thanks,

I've sorted it now
perc = round(cint(oDict(oKey))*0.4)

Thanks for all your help :-)

Oct 11 '06 #7

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

Similar topics

6
by: Bruce Eckel | last post by:
Background: for the 4th edition of Thinking in Java, I'm trying to once again improve the testing scheme for the examples in the book. I want to verify that the output I show in the book is...
7
by: Conax | last post by:
Hello, This is actually a general programming question but I don't know which newsgroup best to put it so please pardon me. I've always been looking for the best way to get an accurate...
3
by: andrew | last post by:
Hello! I have a need to create a function that will return a sublist of elements from a table based on an associated column value and its ranking within the table (based on a percentage range)....
0
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
1
by: Monroeski | last post by:
I am using Access 2003. I am setting up a form where a user selects a Clinic or Ward, beginning date, and ending date, and the form outputs the averages of a few fields based on that criteria. I...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
4
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.