473,785 Members | 2,234 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("Mon itorID1")) > 0 and len(rsMove("Mon itorID2")) > 0 then
response.write ("Dual Monitors")
else if len(rsMove("Mon itorID1")) > 1 and len(rsMove("Mon itorID2")) = 0 then
response.write ("Single Monitor")
else
response.write ("No Monitor")
end if
Jul 22 '05 #1
4 2672
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("Mon itorID1")) > 0 and len(rsMove("Mon itorID2")) > 0
then response.write ("Dual Monitors")
else if


should be a single word: elseif

This would be nested:

if len(rsMove("Mon itorID1")) > 0 and len(rsMove("Mon itorID2")) > 0 then
response.write ("Dual Monitors")
else
if len(rsMove("Mon itorID1")) > 1 and len(rsMove("Mon itorID2")) = 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******@NOyah oo.SPAMcom> wrote in message
news:#3******** ******@TK2MSFTN GP10.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("Mon itorID1")) > 0 and len(rsMove("Mon itorID2")) > 0
then response.write ("Dual Monitors")
else if


should be a single word: elseif

This would be nested:

if len(rsMove("Mon itorID1")) > 0 and len(rsMove("Mon itorID2")) > 0 then
response.write ("Dual Monitors")
else
if len(rsMove("Mon itorID1")) > 1 and len(rsMove("Mon itorID2")) = 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("Mon itorID1")) > 0 _
And Len(rsMove("Mon itorID2")) > 0 Then
Response.Write ("Dual Monitors")
Else
If Len(rsMove("Mon itorID1")) > 1 _
And Len(rsMove("Mon itorID2")) = 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.publi c.inetserver.as p.general:
This version might make it more readable.

It uses the line continuation character: "_".

If Len(rsMove("Mon itorID1")) > 0 _
And Len(rsMove("Mon itorID2")) > 0 Then
Response.Write ("Dual Monitors")
Else
If Len(rsMove("Mon itorID1")) > 1 _
And Len(rsMove("Mon itorID2")) = 0 Then
Response.Write ("Single Monitor")
Else
Response.Write ("No Monitor")
End If
End If


Talking about readability and errorproneness:

D1 = Len(rsMove("Mon itorID1"))
D2 = Len(rsMove("Mon itorID2"))

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("Mon itorID1"))
D2 = Len(rsMove("Mon itorID2"))

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
2569
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: (http://www.python.org/search/hypermail/python-1993/0343.html) "This is because nested function definitions don't have access to the local variables of the surrounding block -- only to the globals of the
0
4354
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 to the event_id. For Q? and Comments I am viewing/updating in a different table than I am question and how_to_answer. The stored proc is populated by a view that I'm using to get all these values from two tables. My quandry is, I am getting the...
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 show an example: classes.hpp classes.cpp util.hpp util.cpp main.cpp // classes.hpp namespace Classes { class MyBaseClass {
3
6472
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 COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
10
3246
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 complexity analyzer tool supposedly does not pick it up. Is it really more efficient? Personally I find this coding style extremely cryptic, misleading and error-prone. I believe that I have removed all traces of proprietary-ness from this coding...
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 like MyClass.MyColors = Color.Green or, a 'get', such as Color forecolor = MyClass.MyColors; I want to use an indexer so I can take parameters, such as the color type (e.g. "Foreground", "Background" etc.). With a single member function I couldn't...
4
1652
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 each category having n question/answer pairs. I would like to pass parameters in the querystring based on what the product/category the user selected, then populate a datagrid with the correct set of question/answer
2
2413
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 answer dialog. The user answers a question, and the next subquestion appears (using dynamic html display:none|block) depending on his answer.
1
11816
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 XmlNodeList. I am trying to deserialize the nodes using a foreach as follows: foreach(XmlNode lineItem in LineItemsNodeList) An abbreviated example of the nested lineItem node looks like this:
3
2128
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 decided to use nested class because I realized that it was the most convenient way to implement my need. Since this feature is supported in many languages, I was just surprised that Python did support it only partially, hence my original email. ...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.