Case For Multiples

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Case For Multiples

Post by jstevens »

Is it possible to have a Case Statment based on multiples?

Example:

Code: Select all

Dim oCounter as Integer

oCounter = 0

Select Case oCounter

Case 1000, 2000, 3000 and so forth  'multiples of 1000
   'Do something
Else Case
   'Do nothing
End Select

oCounter = oCounter +1

Thanks,
John
Regards,
John

User avatar
StuartR
Administrator
Posts: 12628
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Case For Multiples

Post by StuartR »

You could always use

Code: Select all

Select Case oCounter Mod 1000

    Case 0

    Case Else

End Select
StuartR


User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Case For Multiples

Post by HansV »

Or

Code: Select all

If oCounter Mod 1000 = 0 Then
  ' Do something
Else
  ' Do nothing
End If
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Case For Multiples

Post by jstevens »

StuartR/Hans,

Thank you for your suggestions.

John
Regards,
John