select case with dual criterias

  • Thread starter Thread starter Jesper F
  • Start date Start date
J

Jesper F

This function returns 1 even though I feed it 5 and I don't understand why.

Function t(i As Integer)
Select Case i
Case Is > 1, Is < 5
t = 1
Case Is > 4, Is < 11
t = 2
End Select
End Function

Can you help? Thanks.

/ Jesper
 
Function t(i As Integer)
Select Case i
Case 2 To 4
t = 1
Case 5 To 10
t = 2
End Select
End Function

Using commas in a Case Ors them together. You need And, which isn't
supported.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top