Results 1 to 6 of 6

Thread: [RESOLVED] If statement with multiple possible values

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Resolved [RESOLVED] If statement with multiple possible values

    Is this not the correct way to do this? I get an error with it but if I change it to only one value then it works.

    Code:
    If dt2.Rows(0)("STATUS") = "COMP" Or "CLOSE" Or "CAN" Or "INCOMP" Or "WAPPR" Then
    dt.Rows(currentRow).Delete()
    End If

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: If statement with multiple possible values

    Code:
    If dt2.Rows(0)("STATUS") = "COMP" _
    Or dt2.Rows(0)("STATUS") = "CLOSE" _
    Or dt2.Rows(0)("STATUS") = "CAN" _
    Or dt2.Rows(0)("STATUS") = "INCOMP" _
    Or dt2.Rows(0)("STATUS") = "WAPPR" Then

  3. #3
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: If statement with multiple possible values

    Code:
    Select Case dt2.Rows(0)("STATUS")
    Case "COMP", "CLOSE", "CAN", "INCOMP", "WAPPR"
    	dt.Rows(currentRow).Delete()
    End Select
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: If statement with multiple possible values

    This is what I used and it works great. David, yours would have worked too but I used Hack's version because I like for my code to flow like his example.
    Quote Originally Posted by Hack View Post
    Code:
    If dt2.Rows(0)("STATUS") = "COMP" _
    Or dt2.Rows(0)("STATUS") = "CLOSE" _
    Or dt2.Rows(0)("STATUS") = "CAN" _
    Or dt2.Rows(0)("STATUS") = "INCOMP" _
    Or dt2.Rows(0)("STATUS") = "WAPPR" Then

  5. #5
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: [RESOLVED] If statement with multiple possible values

    You might want to change those Or's to OrElse.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: [RESOLVED] If statement with multiple possible values

    Quote Originally Posted by David Anton View Post
    You might want to change those Or's to OrElse.
    Great catch!

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