tags:

views:

50

answers:

1

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

+4  A: 

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
najmeddine
+1. This assumes number is positive though. For example `-1 Mod 4` is `-1`
MarkJ
thanks, fixed. _15_
najmeddine
I already +1-ed, otherwise I would +1 again :)
MarkJ
The Exit Select statements are superfluous
Bill