Alex Gordon
Alex Gordon

Reputation: 60751

working with SELECT CASE and MOD

please help with some basic syntax

i need to make a statement that checks the remainder of a number divided by 4.

this is the logic:

if the remainder of SOMETHING when divided by 4 is 1 then do this
if the remainder of SOMETHING when divided by 4 is 2 then do this
etc etc

can i get this in SELECT CASE ..MOD format please

Upvotes: 0

Views: 1709

Answers (1)

manji
manji

Reputation: 47978

I think yes you can do this:

Dim rem As Integer = number MOD 4

Select Case rem
    Case 0
        '....'
        Exit Select
    Case -3, 1
        '....'
        Exit Select
    Case -2, 2
        '....'     
        Exit Select   
    Case -1, 3
        '....'     
        Exit Select  
End Select

Upvotes: 4

Related Questions