|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Percentage Calculation question....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 = " " end if I just get an error What is the correct way of writing this calculation ? Thanks David "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 = " " > end if > > I just get an error > > > What is the correct way of writing this calculation ? > > Thanks > > 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 = " " > > end if > > > > I just get an error > > > > > > What is the correct way of writing this calculation ? > > > > Thanks > > > > 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 = " " > > > end if > > > > > > I just get an error > > > > > > > > > What is the correct way of writing this calculation ? > > > > > > Thanks > > > > > > David > > > > > --------------------------------------------- Do a Response.Write TypeName(oDict(oKey)) to check. You should also check
the datatype of minstock. -- Show quoteHide quoteMike Brind "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 = " " >> > > end if >> > > >> > > I just get an error >> > > >> > > >> > > What is the correct way of writing this calculation ? >> > > >> > > Thanks >> > > >> > > David >> > > >> >> --------------------------------------------- > David wrote:
Show quoteHide quote > Hi, What error?> > 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 = " " > end if > > I just get an error > > It looks correct to me.> What is the correct way of writing this calculation ? > 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. 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 = " " > > 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 :-)
Other interesting topics
Convert the code from gb2312 to unicode in ASP
retreiving data from html page Quizz script performance bug -- too many questions? interesting problem... Assign Javascript value to asp session variable XML - load contents onto page. how to run a bat file in remote PC through ASP Running Bat file from ASP on Windows Server x64 problem. Richard Mueller... you out there? Msxml2.ServerXMLHTTP¨+ åäö |
|||||||||||||||||||||||