Results 1 to 3 of 3

Thread: Easy If statement prob... [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Easy If statement prob... [RESOLVED]

    Hey all,

    This question is real daft but Im not sure what is wrong with my If statement. I havn't needed to do something like this before and Im getting errors so anyone know what I am doing wrong?

    VB Code:
    1. If CurrentUser <> "User1" Or "User2" Or "User3" Then

    CurrentUser is defined like this:

    VB Code:
    1. Private Function CurrentUser() As String
    2. Dim sBuf As String
    3.  
    4. ' allocate maximum string size
    5. sBuf = String(255, Chr(0))
    6. GetUserName sBuf, 255
    7. CurrentUser = sBuf
    8.  
    9. End Function

    Dont worry, theres no errors with that, It works fine elsewhere and I have the correct API and all.

    Any ideas? Is there such thing as "Or" in an If statement? What else should I do? Thanks

    Btw, I am getting an "Type Mismatch" error
    Last edited by LITHIA; Sep 6th, 2003 at 11:25 AM.

  2. #2
    Junior Member Souled_Out's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    16
    You need to alter your IF statement.

    VB Code:
    1. If CurrentUser <> "User1" Or CurrentUser <> "User2" Or CurrentUser <> "User3" Then

    That should do the trick, it did in a simple test app i just made.

    I'm not certain exactly what the purpose of your app is, but my opinion is that a select case might be a better way to code it instead of using what looks like it could become an infinitely long IF statement.
    Don't mistake lack of talent for genius.

  3. #3

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    thanks, works now

    thought it would have been something simple like that lol, never used Or in my statement before

    thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width