Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with if statement

Posted on 2006-07-07
5
Medium Priority
?
253 Views
Last Modified: 2010-04-23
The following if statement is not working as expected in .NET

   If (MinLevel <> "2") Or (MinLevel <> "3") Or (MinLevel <> "4") Then
                        'this may be the first time thorough put up a messagebox
                        MsgBox("does not match 2, 3 or 4")

                    Else

Even though I see MinLevel = 2 it still says it does not match.  This worked in VB6 as above but I am looking for some insight on how to compare variable x with threee different numbers without having to

if then
elseif...


Thanks in advance for your assistance

-D-






0
Comment
Question by:John Gates, CISSP
[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
  • 2
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 17061500
If MinLevel is a numeric value then you need to drop the quotes. Also if you are checking that the value isn't 2, 3 or 4 then you probably want And rather than Or.

    If (MinLevel <> 2) And (MinLevel <> 3) And (MinLevel <> 4) Then
0
 
LVL 7

Expert Comment

by:davidrichardson
ID: 17061533
       If (MinLevel = "2") Or (MinLevel = "3") Or (MinLevel = "4") Then
            MsgBox("match")
        Else
            MsgBox("No Match")
        End If
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 17061538
MinLevel is a string.  And I am checking if the value IS 2, 3 or 4

The above won't help.  Any ideas?
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 17061572
here is the final and you were right....  (This program has my brain mushy 8)

If (MinLevel <> "2") And (MinLevel <> "3") And (MinLevel <> "4") Then



This is confusing for me coming from the VB6 world as all three things would have to return true for the above to work.  

Thanks!
0
 
LVL 7

Expert Comment

by:davidrichardson
ID: 17061575
?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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