B
Brian Tkatch
RobinS said:Just to add another voice to the cacophony,
sometimes you just HAVE to use nested Ifs.
Yes, sometimes. Most cases not.
B.
RobinS said:Just to add another voice to the cacophony,
sometimes you just HAVE to use nested Ifs.
Brian said:David said:Please re-read the original post. The OP example shows 3 independent tests,
not 3 possible values of an expression.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
I did re-read it before i replied:
For Each [file or whatever] In [some collection]
If [test 1] Then
If [test 2] Then
If [test 3] Then
[Found it]
End If
End If
End If
Next
In this case there's only one "Found it". The assumption is that the
elses will feed the other cases. And that is perfect for a CASE
statement.
B.
Dennis said:For what you have shown, I would suggest "andalso", i.e.,
if test1 andalso test2 andalso test3 then
end if
--
Dennis in Houston
GY2 said:I writing some documentation and I want to describe a common code
structure
which is used to step through all the items in a collection (e.g. each
file
in a subdirectory) while applying more and more restrictive filters so
that
only the desired items can fall all the way through. This method is so
obvious and common it must have a name. What is it or at least, what is
the
best (short) way to describe it?
For Each [file or whatever] In [some collection]
If [test 1] Then
If [test 2] Then
If [test 3] Then
[Found it]
End If
End If
End If
Next
rowe_newsgroups said:Again, I think you're assuming that the if then structure will only
test one variable. In this case you could rewrite it using a Select
Case statement. But with multiple variables if thens are clearly better
suited for this. Take the following adaptation of the OP's structure:
dim a, b, c as integer
a = 5
b = 7
c = 7
if a > 4 then
if b > 6 then
if c > 6 then
msgbox("found it")
end if
end if
end if
How exactly would you rewrite this with a select case?
Thanks,
Seth Rowe
Brian said:David said:Please re-read the original post. The OP example shows 3 independent tests,
not 3 possible values of an expression.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
:
David Anton wrote:
We'll have to agree to disagree then. I find 'Select Case' more appropriate
where you care about many possible values of an expression.
Yes, which is the case in the OPs given example.
B.
I did re-read it before i replied:
For Each [file or whatever] In [some collection]
If [test 1] Then
If [test 2] Then
If [test 3] Then
[Found it]
End If
End If
End If
Next
In this case there's only one "Found it". The assumption is that the
elses will feed the other cases. And that is perfect for a CASE
statement.
B.
Again, I think you're assuming that the if then structure will only
test one variable. In this case you could rewrite it using a Select