if digit is 1 Or 4 Or 7 Or 0

I am trying the query below but it doesn't work. Can't remember how to do this.

something like this??
If intRDigit = In(1,4,7,0) Then

If intRDigit = 1 Or 4 Or 7 Or 0 Then
strtest = "A"
ElseIf intRDigit = 2 Or 5 Or 8 Then
strtest = "B"
Else
strtest = "C"
End If
LVL 1
ShawnAsked:
Who is Participating?
 
cyberkiwiConnect With a Mentor Commented:
If intRDigit = 1 Or intRDigit = 4 Or intRDigit = 7 Or intRDigit = 0 Then
strtest = "A"
ElseIf intRDigit = 2 Or intRDigit = 5 Or intRDigit = 8 Then
strtest = "B"
Else
strtest = "C"
End If
0
 
cyberkiwiCommented:
You can also use this

If InStr(intRDigit, "1470") > 0 Then
    strtest = "A"
ElseIf InStr(intRDigit, "258") > 0 Then
    strtest = "B"
Else
    strtest = "C"
End If

Open in new window

0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Or you could use Select Case -

SELECT CASE IntRDigit
   Case 1,4,7,0
      strtest = "A"
   Case 2, 5, 8
      strtest = "B"
   Case Else
      strtest = "C"
End Select
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
cyberkiwiCommented:
Or use SELECT CASE

Select Case intRDigit
Case 1, 4, 7, 0
    strtest = "A"
Case 2, 5, 8
    strtest = "B"
Case Else
    strtest = "C"
End Select

Open in new window

0
 
ShawnAuthor Commented:
brilliant. thank you for the choice :)

Shawn
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
One Line:

strtest = Choose(strtest + 1, "A", "A", "B", "C", "A", "B", "C", "A", "B")

mx
0
 
cyberkiwiCommented:
@Dbmx

This is both shorter, and correct, as long as intRDigit is >= 0
Your Choose options don't cover more than 0-8.

strtest = Left(Mid("AABCABCAB", intRDigit + 1, 1) + "C", 1)
0
 
ShawnAuthor Commented:
i actually used the select case.
the digits are 0-9. the else covers 3, 6 and 9.
0
 
ShawnAuthor Commented:
the actual strings are quite bit longer than strtest = "A".
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"Your Choose options don't cover more than 0-8."
Either does your Accepted solution  - so what?

And your new solution uses two functions instead of 1 !

mx
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
> i actually used the select case.
So then why wasn't there at least a split?  I posted the select case option...
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"Either does your Accepted solution  - so what?"
Never mind ... I see that it does.  
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
" I posted the select case option..."
Exactly ... First at that ...

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Still one line ... covering any number > 8:

strtest = Nz(Choose(strtest + 1, "A", "A", "B", "C", "A", "B", "C", "A", "B"), "C")

mx
0
 
ShawnAuthor Commented:
leew
>>So then why wasn't there at least a split?
originally I just tested them and gave out the points to the first correct answer.
afterwards I decided which one to use. sorry about that. If you really want I can see if I can't reopen to distribute the points.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Just a suggestion ... sometimes it's best to wait for a few posts, especially when it's clear there will be many possible solutions, some simpler than others :-)

mx
0
 
ShawnAuthor Commented:
good point. thx :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.