473,498 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested If Question

Could someone please look at my code below, I am trying to nest a couple of
if statements together and it is not working. I think I am close.

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
Jul 22 '05 #1
4 2651
Dthmtlgod wrote:
Could someone please look at my code below, I am trying to nest a
not really nested
couple of if statements together and it is not working. I think I am
close.

if len(rsMove("MonitorID1")) > 0 and len(rsMove("MonitorID2")) > 0
then response.write ("Dual Monitors")
else if


should be a single word: elseif

This would be nested:

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

Bob Barrows
--
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.
Jul 22 '05 #2
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:#3**************@TK2MSFTNGP10.phx.gbl...
Dthmtlgod wrote:
Could someone please look at my code below, I am trying to nest a
not really nested
couple of if statements together and it is not working. I think I am
close.

if len(rsMove("MonitorID1")) > 0 and len(rsMove("MonitorID2")) > 0
then response.write ("Dual Monitors")
else if


should be a single word: elseif

This would be nested:

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

Bob Barrows
--
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.


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
(I like capitalizing the first letter of keywords.)
Jul 22 '05 #3
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)

Jul 22 '05 #4
Function GetMonitorCount(str1,str2)
GetMonitorCount = "No Monitor"
intL1 = Len(Trim(str1))
intL2 = intL1 + Len(Trim(str2))
If intL1 > 0 Then
GetMonitorCount = "Single Monitor"
If intL2 > intL1 Then
GetMonitorCount = "Dual Monitor"
End If
End If
End Function

--
dlbjr
Pleading sagacious indoctrination!
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2549
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
0
4332
by: John Wilson | last post by:
Hello, I have the following code which populates as table data from a SQL Server 2000 stored proc (RSByDemoID2). Below that is the view and stored procedure which takes @DemoID as input to match...
3
1204
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
3
6424
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
10
3179
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
6
559
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
4
1634
by: Steve Klett | last post by:
(I posted this in ADO group, but I think this group will be better) Hi- I need to develop an FAQ section for our website. We would like to break up the FAQ by products, then categories with...
2
2397
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and...
1
11752
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
3
2105
by: Cousson, Benoit | last post by:
I don't think so; my original email was mainly a question. I do agree that they are other ways to do what I'm trying to achieve; there are always several ways to solve an issue. Few days ago, I...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.