PDA

View Full Version : Multiline Function Problem?


ping182nz
04-22-2005, 11:58 PM
Hi,

Hi have a simple function as below...


Function comment(FinalScore)
If FinalScore < 1.5 then response.Write("Significant improvement required in all areas")
Else If FinalScore > 3 then response.Write("Sound practice achieved in most areas")
Else If FinalScore > 2.5 then response.Write("Good practices in place but room for improvement")
Else If FinalScore > 2 then response.Write("Improvement required in many areas")
Else response.Write("Significant improvement required in most areas") End if
End Function


But when i cal it when it is written using multilines (like above) it gives the error...
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/self_assess/ref_bus_man_***_results.asp, line 34
Else If FinalScore > 3 then response.Write("Sound practice achieved in most areas")

When written on one line..like...

Function comment(FinalScore)
If FinalScore < 1.5 then response.Write("Significant improvement required in all areas") Else If FinalScore > 3 then response.Write("Sound practice achieved in most areas") Else If FinalScore > 2.5 then response.Write("Good practices in place but room for improvement") Else If FinalScore > 2 then response.Write("Improvement required in many areas") Else response.Write("Significant improvement required in most areas") End if
End Function


THE ABOVE CODE WORKS....

Any help please?????

miranda
04-23-2005, 08:42 AM
1st) it is ElseIf not Else If unless you format it as below notice that each needs an end if

If (Condition) Then
instruction when true
Else
If (Condition) Then
instruction when true
End If
End If


2nd) Any time you have an else or an elseif statement then you need to put the code on multiple lines and cannot code it as you would a single line if statement

Function comment(FinalScore)
If FinalScore < 1.5 then
response.Write("Significant improvement required in all areas")
ElseIf FinalScore > 3 then
response.Write("Sound practice achieved in most areas")
ElseIf FinalScore > 2.5 then
response.Write("Good practices in place but room for improvement")
ElseIf FinalScore > 2 then
response.Write("Improvement required in many areas")
Else
response.Write("Significant improvement required in most areas")
End if
End Function