Re: One more ! Calculating Recordset Values
- From: "RobA" <anon@xxxxxxxxxxx>
- Date: Tue, 08 Nov 2005 13:06:38 GMT
I did test it, however, I had the same value in each of the fields so I
couldn't really see what you were meaning.
I now realise that the I am nutter lol. It is back to the drawing board by
the looks of things.
Thanks for you help though.
Rob
"Stefan B Rusynko" <sbr_enjoy@xxxxxxxxxxx> wrote in message
news:eClfrKG5FHA.1148@xxxxxxxxxxxxxxxxxxxxxxx
> Did you really test it w/i each of the loops using the VBscript function:
> TypeName("yourvarname")
> - per my 1st post?
>
> PS
> A zero in some of the fields will give you divide by 0 errors unless you
> test for them 1st
>
> And again your whole logic appears to be flawed since there is nothing
> controlling the order (or grouping) of the numbers you are
> doing math on - the results will be totally random
> --
>
> _____________________________________________
> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
> "Warning - Using the F1 Key will not break anything!" (-;
> To find the best Newsgroup for FrontPage support see:
> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
> _____________________________________________
>
>
> "RobA" <anon@xxxxxxxxxxx> wrote in message
> news:4S0cf.9294$Cq4.5080@xxxxxxxxxxxxxxxxxxxxxxx
> | It is a decimal field in the database that is being pulled into the
> | recordset.
> |
> | There are the same amount of records in each recordset.
> |
> | I have tested it without the calculations and all of the recordset
> values
> | are returned and can be written, just can't do any calculation.
> |
> | Rob
> | "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> | news:umLjn8F5FHA.1416@xxxxxxxxxxxxxxxxxxxxxxx
> | > What is the dat type of these fields?
> | >
> | > --
> | > HTH,
> | >
> | > Kevin Spencer
> | > Microsoft MVP
> | > .Net Developer
> | > Complex things are made up of
> | > Lots of simple things.
> | >
> | > "RobA" <anon@xxxxxxxxxxx> wrote in message
> | > news:T00cf.4397$8R6.1482@xxxxxxxxxxxxxxxxxxxxxxx
> | >> Cheers for that Stefan,
> | >>
> | >> I had been working along the same principle - but I must be getting
> | >> something wrong. I have included my script !!!
> | >> The db where the data is being drawn from requires a value for each
> of
> | >> the recordset fields (it is a , so there shouln't be a return of an
> EOF,
> | >> this page can't be ran until all the values are input. (although I am
> | >> hoping a value of 0 wont be returned as a NULL).
> | >>
> | >> I just keep getting a
> | >>
> | >> Type mismatch
> | >> /ia/calc01.asp, line 175
> | >>
> | >> which seems to happen whenever I attempt any caluculations.
> | >>
> | >> <%
> | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal,
> | >> Total, aStrengthTotal
> | >>
> | >> aTot = 0
> | >> eTot = 0
> | >> iTot = 0
> | >> pSubTot = 0
> | >> aStrengthSubTot = 0
> | >> pTotal = 0
> | >> SubTotal = 0
> | >> aStrengthTotal = 0
> | >>
> | >> 'Create Table Header
> | >> Response.Write "<Table align=center border=1 cellpadding=0
> | >> cellspacing=0>"
> | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
> | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
> | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD
> | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD WIDTH=120
> | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
> WIDTH=120><FONT
> | >> Face=Arial Size=3>Asset Strength</TD></TR>"
> | >>
> | >> ' Start Processes
> | >> 'Transfer recordset values to equation values
> | >> Do While not aScrRst.EOF
> | >> aTot = aScrRst("Score")
> | >> Do While not eScrRst.EOF
> | >> eTot = eScrRst("Score")
> | >> Do While not iScrRst.EOF
> | >> iTot = iScrRst("Score")
> | >>
> | >>
> | >>
> | >>
> | >>
> | >> 'The Calculated Value = 1st and 2nd scores added then multiplied by
> 3rd
> | >> (this calculation is where the error is returned)
> | >> SubTotal = aTot + eTot * eTot
> | >>
> | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
> mulitplied by
> | >> 20
> | >> pSubTot = iTot * 20 * 20
> | >>
> | >> 'The Asset Strength Sub Total = Calculated Value devided by the
> Potential
> | >> Value multiplied 100
> | >> aStrengthSubTot = SubTotal / pSubTot * 100
> | >>
> | >> 'Total = The sum of all the SubTotals
> | >> Total = Total + Subtotal
> | >>
> | >> 'Potential Total
> | >> pTotal = pTotal + pSubTot
> | >>
> | >>
> | >> Response.Write "<Table align=center border=1 cellpadding=0
> | >> cellspacing=0>"
> | >>
> | >> Response.Write "<TR ALIGN=CENTER>"
> | >>
> | >> Response.Write "<TD WIDTH=60>"
> | >> Response.Write aTot
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "<TD WIDTH=60>"
> | >> Response.Write eTot
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "<TD WIDTH=60>"
> | >> Response.Write iTot
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "<TD WIDTH=120>"
> | >> Response.Write pSubTot
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "<TD WIDTH=120>"
> | >> Response.Write SubTotal
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "<TD WIDTH=120>"
> | >> Response.Write aStrength
> | >> Response.Write "</TD>"
> | >>
> | >> Response.Write "</TR>"
> | >>
> | >> Response.Write "<Table>"
> | >>
> | >>
> | >> aScrRst.MoveNext
> | >> eScrRst.MoveNext
> | >> iScrRst.MoveNext
> | >>
> | >>
> | >> Loop
> | >> Loop
> | >> Loop
> | >> Response.Write "Total=" & Total
> | >> Response.Write "Potential Total= " & PTotal
> | >> aStrengthTotal = Total /PTotal * 100
> | >> Response.Write "Asset Strength= " & aStrengthTotal
> | >>
> | >>
> | >> %>
> | >> "Stefan B Rusynko" <sbr_enjoy@xxxxxxxxxxx> wrote in message
> | >> news:usz56GF5FHA.2396@xxxxxxxxxxxxxxxxxxxxxxx
> | >>> Validate your data types in each loop while testing using say:
> | >>>
> | >>> <%
> | >>> Do While not aScrRst.EOF
> | >>> aScore = aScrRst("Score")
> | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test
> line
> | >>> Do While not eScrRst.EOF
> | >>> eScore = eScrRst("Score")
> | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test
> line
> | >>> Do While not iScrRst.EOF
> | >>> iScore = iScrRst("Score")
> | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test
> line
> | >>> Total = iScore + eScore * aScore
> | >>> Response.Write "Total: " & Total & "<br>" 'test line
> | >>> GrandTotal = GrandTotal + Total
> | >>> iScrRst.MoveNext
> | >>> eScrRst.MoveNext
> | >>> aScrRst.MoveNext
> | >>> Loop
> | >>> Loop
> | >>> Loop
> | >>> Response.Write "GrandTotal: " & GrandTotal
> | >>> %>
> | >>>
> | >>> I suspect 1 of your loops may be returning an EOF since your logic
> is
> | >>> requiring all 3 recordsets to have 3 "identical" sets of
> | >>> qualifying data in each loop (a null value or empty string in any
> | >>> recordset will also cause the loops to fail)
> | >>>
> | >>> PS
> | >>> Plus your logic will result in unreliable results since there is no
> | >>> attempt to order or group the recordset results in any
> | >>> associated way that is consistent or related to iScore, eScore, or
> | >>> aScore as a group
> | >>> So you will be doing math on 3 random numbers (depending on each
> | >>> recordset order returned)
> | >>> --
> | >>>
> | >>> _____________________________________________
> | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
> | >>> "Warning - Using the F1 Key will not break anything!" (-;
> | >>> To find the best Newsgroup for FrontPage support see:
> | >>>
> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
> | >>> _____________________________________________
> | >>>
> | >>>
> | >>> "RobA" <anon@xxxxxxxxxxx> wrote in message
> | >>> news:okZbf.15943$Gy5.15608@xxxxxxxxxxxxxxxxxxxxxxx
> | >>> | Thanks but I am still getting a type mismatch error.
> | >>> | "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
> message
> | >>> | news:OQe%23HzB5FHA.3876@xxxxxxxxxxxxxxxxxxxxxxx
> | >>> | > <%
> | >>> | > Dim Total
> | >>> | > Dim GrandTotal
> | >>> | > GrandTotal = 0
> | >>> | > Do While not aScrRst.EOF
> | >>> | > Do While not eScrRst.EOF
> | >>> | > Do While not iScrRst.EOF
> | >>> | > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
> | >>> | > GrandTotal = GrandTotal + Total
> | >>> | >
> | >>> | > Response.Write "Total: " & Total
> | >>> | >
> | >>> | > aScrRst.MoveNext
> | >>> | > eScrRst.MoveNext
> | >>> | > iScrRst.MoveNext
> | >>> | >
> | >>> | > Loop
> | >>> | > Loop
> | >>> | > Loop
> | >>> | > Response.Write "GrandTotal: " & GrandTotal
> | >>> | >
> | >>> | > --
> | >>> | > HTH,
> | >>> | >
> | >>> | > Kevin Spencer
> | >>> | > Microsoft MVP
> | >>> | > .Net Developer
> | >>> | > A watched clock never boils.
> | >>> | >
> | >>> | >
> | >>> | > "RobA" <anon@xxxxxxxxxxx> wrote in message
> | >>> | > news:v0Sbf.8228$lJ.3691@xxxxxxxxxxxxxxxxxxxxxxx
> | >>> | >> Can anyone point me in the direction of some guidance for
> handling
> | >>> | >> recordset values.
> | >>> | >>
> | >>> | >> I am trying to calculate a resultant value (total) of adding 2
> | >>> values and
> | >>> | >> mulitplying by the third.
> | >>> | >>
> | >>> | >> Eventually I wanted to get total for the resultant value (all
> the
> | >>> totals
> | >>> | >> added together) for the whole recordset!
> | >>> | >>
> | >>> | >> <%
> | >>> | >> Dim Total
> | >>> | >> Do While not aScrRst.EOF
> | >>> | >> Do While not eScrRst.EOF
> | >>> | >> Do While not iScrRst.EOF
> | >>> | >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
> | >>> | >>
> | >>> | >> Response.Write "Total"
> | >>> | >>
> | >>> | >> aScrRst.MoveNext
> | >>> | >> eScrRst.MoveNext
> | >>> | >> iScrRst.MoveNext
> | >>> | >>
> | >>> | >>
> | >>> | >> Loop
> | >>> | >> Loop
> | >>> | >> Loop
> | >>> | >> %>
> | >>> | >>
> | >>> | >
> | >>> | >
> | >>> |
> | >>> |
> | >>>
> | >>>
> | >>
> | >>
> | >
> | >
> |
> |
>
>
.
- Follow-Ups:
- Re: One more ! Calculating Recordset Values
- From: Stefan B Rusynko
- Re: One more ! Calculating Recordset Values
- References:
- One more ! Calculating Recordset Values
- From: RobA
- Re: One more ! Calculating Recordset Values
- From: Kevin Spencer
- Re: One more ! Calculating Recordset Values
- From: RobA
- Re: One more ! Calculating Recordset Values
- From: Stefan B Rusynko
- Re: One more ! Calculating Recordset Values
- From: RobA
- Re: One more ! Calculating Recordset Values
- From: Kevin Spencer
- Re: One more ! Calculating Recordset Values
- From: RobA
- Re: One more ! Calculating Recordset Values
- From: Stefan B Rusynko
- One more ! Calculating Recordset Values
- Prev by Date: Re: One more ! Calculating Recordset Values
- Next by Date: Re: One more ! Calculating Recordset Values
- Previous by thread: Re: One more ! Calculating Recordset Values
- Next by thread: Re: One more ! Calculating Recordset Values
- Index(es):
Relevant Pages
|