Home All Groups Group Topic Archive Search About

Percentage Calculation question....

Author
11 Oct 2006 1:14 PM
David
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

Author
11 Oct 2006 1:38 PM
Ray Costanzo [MVP]
"I just get an error."

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

Ray at work


Show quoteHide quote
"David" <davidgor***@scene-double.co.uk> wrote in message
news:1160572478.438367.271330@m73g2000cwd.googlegroups.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
>
Are all your drivers up to date? click for free checkup

Author
11 Oct 2006 1:50 PM
David
Hi Ray,

It is a calculated integer. A sum of a calculation

David

-------------------------------------------------------
Ray Costanzo [MVP] wrote:
Show quoteHide quote
> "I just get an error."
>
> What's the error?!  What's the value of oDict(oKey)?
>
> Ray at work
>
>
> "David" <davidgor***@scene-double.co.uk> wrote in message
> news:1160572478.438367.271330@m73g2000cwd.googlegroups.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
> >

---------------------------------------------
Author
11 Oct 2006 1:51 PM
David
>>>

Microsoft VBScript runtime  error '800a000d'

Type mismatch

/L&R/Metal/complete_orderbook_view.asp, line 120


David wrote:
Show quoteHide quote
> 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" <davidgor***@scene-double.co.uk> wrote in message
> > news:1160572478.438367.271330@m73g2000cwd.googlegroups.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
> > >
>
> ---------------------------------------------
Author
11 Oct 2006 2:37 PM
Mike Brind
Do a Response.Write TypeName(oDict(oKey)) to check.  You should also check
the datatype of minstock.

--
Mike Brind


Show quoteHide quote
"David" <davidgor***@scene-double.co.uk> wrote in message
news:1160574705.969204.59820@e3g2000cwe.googlegroups.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" <davidgor***@scene-double.co.uk> wrote in message
>> > news:1160572478.438367.271330@m73g2000cwd.googlegroups.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
>> > >
>>
>> ---------------------------------------------
>
Author
11 Oct 2006 1:39 PM
Bob Barrows [MVP]
David wrote:
Show quoteHide quote
> 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.
Author
11 Oct 2006 3:10 PM
David
Bob Barrows [MVP] wrote:
Show quoteHide quote
> 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  :-)

Bookmark and Share