Author |
Topic  |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 23 July 2001 : 11:00:39
|
Heya
yet another question for you kind people...
I have 8 fields that I need to work out the average score from, not a problem. The confusion occurs when the result in the box is anything other than 0 - 100. If it is anything else I need to ignore this value and reduce the number to divide by by one each time.
Is the best way to do this just one long set of IF statements and reduce the number of a "Divide by" counter by one for each incorrect value?
thanks
Paul - Complete Muppet, Borderline Feeble! |
|
Spoon
Average Member
  
Ireland
507 Posts |
Posted - 23 July 2001 : 12:18:39
|
quote:
Heya
yet another question for you kind people...
I have 8 fields that I need to work out the average score from, not a problem. The confusion occurs when the result in the box is anything other than 0 - 100. If it is anything else I need to ignore this value and reduce the number to divide by by one each time.
Is the best way to do this just one long set of IF statements and reduce the number of a "Divide by" counter by one for each incorrect value?
thanks
Paul - Complete Muppet, Borderline Feeble!
Im not too sure what you mean, but if you do mean you are getting un-even integers in the box, then i can help.
If its not a whole number, eg. 50.2567 you can use the "Cint" method to round it off to the nearest number. E.g.
AVERAGEVALUE = (whatever var you use) AVERAGEVALUE = Cint(AVERAGEVALUE)
Hope this is what you need
Regards,
Spoon, (ya all love me right?) |
 |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 23 July 2001 : 12:25:10
|
Sorry.. I was too vague.
I need to work out the average percentile score, but I'm not able to hardcode in the value to divide by as some values could be set to N/A
for example if someone filled in all 8 score boxes on my form then I would add together the 8 results and divide by 8.
BUT
if three of the boxes are not applicable to the project that needs scoring they will only fill in 5 of the boxes and mark three as N/A. In this case I need the page to work out that it only needs to add up 5 scores and divide by 5 rather than 8
I hope that's clearer
Paul - Complete Muppet, Borderline Feeble!
Edited by - sogoth on 23 July 2001 12:26:18 |
 |
|
Spoon
Average Member
  
Ireland
507 Posts |
Posted - 23 July 2001 : 12:29:13
|
quote:
Sorry.. I was too vague.
I need to work out the average percentile score, but I'm not able to hardcode in the value to divide by as some values could be set to N/A
for example if someone filled in all 8 score boxes on my form then I would add together the 8 results and divide by 8.
BUT
if three of the boxes are not applicable to the project that needs scoring they will only fill in 5 of the boxes and mark three as N/A. In this case I need the page to work out that it only needs to add up 5 scores and divide by 5 rather than 8
I hope that's clearer
Paul - Complete Muppet, Borderline Feeble!
Edited by - sogoth on 23 July 2001 12:26:18
There is porbably another way, but i would use if statements
If VALUE_ONE = "" Then VALUE_ONE = "0" End If
Its not as if its a big task, you only have 8 boxes,
Hope this helps,
Regards,
Spoon, (ya all love me right?) |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 23 July 2001 : 12:47:18
|
Look at the IsNumeric() function to test your values.
====== Doug G ====== |
 |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 25 July 2001 : 11:44:22
|
Sorry to be a complete and utter pain, but could someone kindly point out where I've gone wrong with this one?
I'm getting :-
Microsoft VBScript runtime error '800a01a8' Object required: '' /cro/proj_detail.asp, line 590
returned when I try and run the following..
--- --- <%@LANGUAGE="VBSCRIPT"%> <!--#include file="file:///C|/Inetpub/wwwroot/cro/Connections/cro.asp" --> <% set calculation = Server.CreateObject("ADODB.Recordset") calculation.ActiveConnection = MM_cro_STRING calculation.Source = "SELECT * FROM dbo.Performance WHERE proj = 21" calculation.CursorType = 0 calculation.CursorLocation = 2 calculation.LockType = 3 calculation.Open() calculation_numRows = 0 %> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <% DIM counter, score
if calculaion.Fields.Item("Setup").Value = 200 then score = score counter = 7 Else score = calculaion.Fields.Item("Setup").Value counter = 8 End if if calculaion.Fields.Item("management").Value = 200 then score = score counter = counter - 1 Else score = score + calculaion.Fields.Item("management").Value end if if calculaion.Fields.Item("Quality").Value = 200 then score = score counter = counter - 1 Else score = score + calculaion.Fields.Item("Quality").Value end if if calculaion.Fields.Item("Communic").Value = 200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Communic").Value end if if calculaion.Fields.Item("Timeline").Value = 200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Setup").Value end if if calculaion.Fields.Item("Scientific").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Scientific").Value end if if calculaion.Fields.Item("value").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("value").Value end if if calculaion.Fields.Item("Team_perfrmance").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Team_perfrmance").Value End if if score = 0 then response.write N/A Else response.write score response.write "<br>" response.write counter response.write "<P>" score = score/counter response.write score end if %> </body> </html> <% calculation.Close() %> --- ---
the fields being referred to only contain 0, 25, 50, 75, 100 or 200 as their values.
thanks
Paul - Complete Muppet, Borderline Feeble! |
 |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 25 July 2001 : 11:46:21
|
Doh! that was meant to be an error on line 22
serves me right for cutting down the actual file to show the important bit ;)
Paul - Complete Muppet, Borderline Feeble! |
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 25 July 2001 : 12:51:27
|
I think you can use something like this. I may be wrong on how to get the count. I will look for that.
FieldCount = calculation.fields.count - 1 counter = calculation.fields.count - 1 score = 0 for i = 0 to FieldCount if calculaion.Fields.Item(i).Value = 200 then score = score counter = counter - 1 else score = score + calculaion.Fields.Item(i).Value End if next
Checkout forumSquare
gauravbhabu
There is only one miracle...That is LIFE!
Edited by - gauravbhabu on 25 July 2001 13:31:53
Edited by - gauravbhabu on 25 July 2001 13:34:20 |
 |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 02 August 2001 : 08:43:36
|
Thanks but I'd quite like to know what I've managed to mistype in the previous code sample if possible. It's driving me nuts...
Paul - Complete Muppet, Borderline Feeble! |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 02 August 2001 : 12:13:49
|
quote: if calculaion.Fields.Item("Setup").Value = 200 then score = score counter = 7 Else score = calculaion.Fields.Item("Setup").Value counter = 8 End if if calculaion.Fields.Item("management").Value = 200 then score = score counter = counter - 1 Else score = score + calculaion.Fields.Item("management").Value end if if calculaion.Fields.Item("Quality").Value = 200 then score = score counter = counter - 1 Else score = score + calculaion.Fields.Item("Quality").Value end if if calculaion.Fields.Item("Communic").Value = 200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Communic").Value end if if calculaion.Fields.Item("Timeline").Value = 200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Setup").Value end if if calculaion.Fields.Item("Scientific").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Scientific").Value end if if calculaion.Fields.Item("value").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("value").Value end if if calculaion.Fields.Item("Team_perfrmance").Value=200 then score = score counter = counter -1 Else score = score + calculaion.Fields.Item("Team_perfrmance").Value End if
You have spelled calculation differently in this block of code.
====== Doug G ====== |
 |
|
sogoth
New Member

United Kingdom
73 Posts |
Posted - 03 August 2001 : 05:46:45
|
DOH! stupid stupid me! I knew it'd be something blatantly obvious!
thank you very much!!
Paul - Complete Muppet, Borderline Feeble! |
 |
|
GauravBhabu
Advanced Member
    
4288 Posts |
Posted - 03 August 2001 : 06:31:21
|
That was a good sighting Doug.
Share A Square at forumSquare
gauravbhabu
There is only one miracle...That is LIFE! |
 |
|
|
Topic  |
|