Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

operator question

Posted on 2004-04-08
5
Medium Priority
?
237 Views
Last Modified: 2010-04-15
here is the code:

if ((sFileExtension != ".doc") || (sFileExtension != ".txt"))
{

}

im looking to see if uploaded file is either .doc OR .txt


the above doesnt work. how come?

0
Comment
Question by:tmueller18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 5

Accepted Solution

by:
millsoft earned 1000 total points
ID: 10784768
Hi tmueller18,

Your boolean operators are wrong.

if ((sFileExtension == ".doc") || (sFileExtension == ".txt"))
{
    // extension is .DOC or .TXT
}
else
{
    // it is not
}

Cheers!
Brad
0
 
LVL 5

Expert Comment

by:millsoft
ID: 10784784
!= is "NOT EQUALS"
== is "EQUALS"

You were checking to see if the extension is "NOT .DOC or NOT .TXT".  One of those conditions will ALWAYS be true.
0
 
LVL 5

Expert Comment

by:millsoft
ID: 10784791
>One of those conditions will ALWAYS be true.

because it cannot be both at the same time.
0
 

Author Comment

by:tmueller18
ID: 10784795
thanks!
0
 
LVL 5

Expert Comment

by:millsoft
ID: 10784813
happy to help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question