can someone give me examples of If Then statements..
Printable View
can someone give me examples of If Then statements..
You are a lively member. Not that this really means anything, but If Then Statements are basic to programming from the beginning.
Is there something specific you are looking for?
I agree, you should have learned If...Then...Else statements within the first 2 weeks of any programming class.
VB Code:
Dim a As Integer a = 10 If(a = 10) then 'process some code here Else 'process some code here End If
Oh, and please don't double post...You have 8 replies in your other post asking the same question.
I'm new at all this so I don't mind helping with IF/Then/Else 101:
Here are some basics:
If A = B then
do something
end if
If A = B then
do something
elseif A = C then
do something else
end if
If A = B then
If A = C then
do something
end if
else
end if
It helps alot if you use proper indentation.
I'm new at all this so I don't mind helping with IF/Then/Else 101:
Here are some basics:
If A = B then
do something
end if
If A = B then
do something
elseif A = C then
do something else
end if
If A = B then
If A = C then
do something
end if
else
do something else
end if
It helps alot if you use proper indentation.
The way I use it.
If your testing one condition expression against several possible values then use Select Case instead of If...ElseIf...End If
VB Code:
Select Case A Case B 'Statements Case C 'Statements Case Else 'A <> B, A <> C 'Statements End Select
If your testing several condition expressions then use If...ElseIf...End If.
VB Code:
If A = B Then 'Statements ElseIf A + C = B Then 'Statements Else 'Statements End If
I hardly use If...ElseIf...End If. Add an About Form to see a sample of If...ElseIf...End If.
I don't think any of us mind helping. In fact, Memnoch1207 even gave an example. I just wanted to know more specifics to give a better answer.
Now I understand. Personally, I love the SELECT statement. I prefer that over ELSEIF. That just looks to confusing. The SELECT statement I think is much cleaner.
Just my humble (only a 'member') opinion.
How does one use proper indention on this website anyway?
And there's this :
VB Code:
Iff(a=1,b=1,b=2)
Enclose "vbcode" in brackets to start the code sample, then enclose "/vbcode" in brackets to end the sample. (Without the quotes)Quote:
Originally posted by Virgil J. Schmidt
How does one use proper indention on this website anyway? [/B]
True, True
I thougth of that, but I usually use that to complete an equation.
X = iff(a=y, b,c)
So I didn't consider it was the same in this case.
Thank you.Quote:
Originally posted by demotivater
Enclose "vbcode" in brackets to start the code sample, then enclose "/vbcode" in brackets to end the sample. (Without the quotes)
So
VB Code:
X = iff(a=y, b,c)
Hey, it works...Sorry for the thread interuption.