Select Case Problem

Select Case Problem

isocam
Collaborator Collaborator
213 Views
2 Replies
Message 1 of 3

Select Case Problem

isocam
Collaborator
Collaborator
I have a problem with select case that I hope somebody can help me with.

I have a variable "NumberOfEntities"

If the Counter is 1 then one thing happens

If the Counter is greater than 1 but less than NumberOfEntities then another thing happens

and finally.....

If the counter is equal to the NumberOfEntities then I want the programme to do something else

But I cannot get the programme to work.

Can anybody help?

Here is my code.......


NumberOfEntities = 7

For Counter = 1 To NumberOfEntities

Select Case Counter
Case 1
MsgBox Counter, 64, "Counter is 1"
Case Is > 1 And Counter < NumberOfEntities
MsgBox Counter, 64, "Counter is greater than 1 but less than NumberOfEntities"
Case Is = NumberOfEntities
MsgBox Counter, 64, "Counter is equal to the NumberOfEntities"
End Select

Next

Kind Regards

Darren
0 Likes
214 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Try:

 

NumberOfEntities = 7

For Counter = 1 To
NumberOfEntities
 
  Select Case Counter
   
Case 1
         MsgBox Counter, 64,
"Counter is 1"
    Case
NumberOfEntities
         MsgBox
Counter, 64, "Counter is equal to the NumberOfEntities"
   
Case Else

        
MsgBox Counter, 64, "Counter is greater than 1 but less than
NumberOfEntities"
  End Select
 
Next



Brian R.
Iwaskewycz


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">CAD Systems
Manager


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">
href="http://www.corefurnace.com/">Core Furnace Systems

0 Likes
Message 3 of 3

Anonymous
Not applicable
You can also use the 'To' operand to specify a range of values.
------
[code]
Private Sub Command1_Click()
Dim a As Integer
a = 62

Select Case a
Case 1
MsgBox "A = 1"
Case 2 To 63
MsgBox "A = " & a
Case 64
MsgBox "A = Top Value"
End Select
End Sub

[/code]
0 Likes