|
-
Sep 6th, 2003, 11:10 AM
#1
Thread Starter
Fanatic Member
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:
If CurrentUser <> "User1" Or "User2" Or "User3" Then
CurrentUser is defined like this:
VB Code:
Private Function CurrentUser() As String
Dim sBuf As String
' allocate maximum string size
sBuf = String(255, Chr(0))
GetUserName sBuf, 255
CurrentUser = sBuf
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.
-
Sep 6th, 2003, 11:22 AM
#2
Junior Member
You need to alter your IF statement.
VB Code:
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.
-
Sep 6th, 2003, 11:24 AM
#3
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|