TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
HumptyNotSoDumpty
NA
23
0
Use of Multiple Test Expressions in an 'If' Statement
Jul 26 2004 8:27 AM
Can anyone clarify for me please, as to whether you can specify more than one expression in the test part of an 'If' statement. I would like to check for two, or more, conditions in my 'If' statement. In the case the none of the conditions are met, I want the same 'else' statement to be executed. I have tried various techniques: if(test1) _____if(test2) MessageBox.Show("HelloWorld"); else MessageBox.Show("GoodbyeWorld"); if(test1) { _____if(test2) MessageBox.Show("HelloWorld"); } else MessageBox.Show("GoodbyeWorld"); But have have come to the conclusion that I will have to repeat the else part twice, which surely cant be so. In VB you can do the following: If (Test1 = true) Or (Test2 = true) Then _____MessageBox.Show("HelloWorld") Else _____MessageBox.Show("GoodbyeWorld") End If Can someone put me out of my misery, in a kind and gentle way please!
Reply
Answers (
2
)
Control drawing
checking for selection in listbox