Nested If

  • Thread starter Thread starter Thanks2U
  • Start date Start date
T

Thanks2U

I have 2 if statements that are unrelated to each other,
but the outcome of the variable of each of these are.
Here is my first one:

If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
sTo = sToEMail
End If

Then my second one:

If iCall_Type = 9 Then
sTo = sCmd
End if

Both IF's need to be evaluated, but not sure how to
handle this with the outcome of the sTo variable.

Help?

Thanks!
 
Hi,

What is sCmd?

In any case, it seems straightforward - if this is the code sequence, sTo
ends up being the designated email address or sCmd. What am I missing here?

Bernie
 
Thanks2U said:
I have 2 if statements that are unrelated to each other,
but the outcome of the variable of each of these are.
Here is my first one:

If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
sTo = sToEMail
End If

Then my second one:

If iCall_Type = 9 Then
sTo = sCmd
End if

Both IF's need to be evaluated, but not sure how to
handle this with the outcome of the sTo variable.

Help?

Thanks!

If iCall_Type = 9 Then
sTo = sCmd
ElseIf sToEmail = "" Then
sTo = "DT" & CStr(lDistrictNbr) & "@microsoft.com"
Else
sTo = sToEMail
End If

Is this what you need?

Mythran
 
* "Thanks2U said:
I have 2 if statements that are unrelated to each other,
but the outcome of the variable of each of these are.
Here is my first one:

If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
sTo = sToEMail
End If

Then my second one:

If iCall_Type = 9 Then
sTo = sCmd
End if

Both IF's need to be evaluated, but not sure how to
handle this with the outcome of the sTo variable.

\\\
If ... Then
...
ElseIf ... Then
...
ElseIf ... Then
...
End If
///
 
He indicated that both If's need to be evaluated. In yours,

ElseIf sToEmail = "" Then

will not be tested if: iCall_Type = 9
 
I did not understand the question, now I saw the message from Scott I
understand it.
If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
If iCall_Type = 9 Then
sTo = sCmd
else
sTo = sToEMail
End if
///

Cor
 
I still don't think that this will satisfy the original requirement that
both if statements be evaluated. In yours, if:

oEMail = ""

then iCall_Type will not be tested for 9.

I think he just needs the 2 if statements, one after the other.

His original post showed him ussing:

If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
sTo = sToEMail
End If

If iCall_Type = 9 Then
sTo = sCmd
End if

This seems to be correct to me. The question now becomes, which if is more
important than the other. If he has one variable that will be changed by
one of 2 other variable values, then is it more important that sTo be sCmd
when iCall_Type is 9 or not. The order of the if statements may need to be
reversed.
 
In your sample will the previous test be for nothing if cmd = 9

If the 9 test would be the most important, than it should in my example have
to change place with the test for space
 
Not sure what test you mean by "previous test", but in my example (actually
the original post's example), both tests are carried out.

I just don't see how your nested If test in the Else section would be
carried out if the first If returns true.
 
There is a typo in, but I asume that you did see that the last "end if" was
missing.
If sToEMail = "" Then

(if there is no emailadres send a mail to microsoft)
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"

(if there is an mail adres than do something else)
If iCall_Type = 9 Then

(if it is a Icall, let say intern, than do this)
sTo = sCmd
else
(send to the email adres)
sTo = sToEMail
end if
End if
///
 
Back
Top