Re: Nested If Question
From: Evertjan. (exjxw.hannivoort_at_interxnl.net)
Date: 02/16/05
- Next message: Dave Anderson: "Re: ASP Sessions"
- Previous message: ctindog_at_access4less.net: "NEED HELP: Error 405 Method not allowed"
- In reply to: McKirahan: "Re: Nested If Question"
- Next in thread: dlbjr: "Re: Nested If Question"
- Messages sorted by: [ date ] [ thread ]
Date: 16 Feb 2005 22:31:17 GMT
McKirahan wrote on 16 feb 2005 in
microsoft.public.inetserver.asp.general:
> This version might make it more readable.
>
> It uses the line continuation character: "_".
>
> If Len(rsMove("MonitorID1")) > 0 _
> And Len(rsMove("MonitorID2")) > 0 Then
> Response.Write ("Dual Monitors")
> Else
> If Len(rsMove("MonitorID1")) > 1 _
> And Len(rsMove("MonitorID2")) = 0 Then
> Response.Write ("Single Monitor")
> Else
> Response.Write ("No Monitor")
> End If
> End If
>
Talking about readability and errorproneness:
D1 = Len(rsMove("MonitorID1"))
D2 = Len(rsMove("MonitorID2"))
If D1 > 0 And D2 > 0 Then
r = "Dual Monitors"
ElseIf D1 > 1 And D2 = 0 Then
r = "Single Monitor"
Else
r = "No Monitor"
End If
Response.Write r
====================
Then you immediately would see that
D1 > 1
most probably would need to be
D1 > 0
and that the case of
D1 = 0 And D2 > 0
would erroneously return "No Monitor"
====================
so this would probably be best:
====================
D1 = Len(rsMove("MonitorID1"))
D2 = Len(rsMove("MonitorID2"))
If D1 > 0 And D2 > 0 Then
r = "Dual Monitors"
ElseIf D1 > 0 Or D2 > 0 Then
r = "Single Monitor"
Else ' meaning: D1 = 0 And D2 = 0
r = "No Monitor"
End If
Response.Write r
-- Evertjan. The Netherlands. (Replace all crosses with dots in my emailaddress)
- Next message: Dave Anderson: "Re: ASP Sessions"
- Previous message: ctindog_at_access4less.net: "NEED HELP: Error 405 Method not allowed"
- In reply to: McKirahan: "Re: Nested If Question"
- Next in thread: dlbjr: "Re: Nested If Question"
- Messages sorted by: [ date ] [ thread ]