Check for Number's Odd/Even Type

Naimishforu
Posted by Naimishforu under VB.NET category on | Points: 40 | Views : 2358
Recently I need to loop two numbers and wanted to add one number in first line and other number in second line,

I came up doing this,


If (index Mod 2 = 0) Then
'value
first item = Item1
Else
second item = item2
End If

(index Mod 2 = 0) will tell me if number is even or not.

for example,

?0 Mod 2
0
?1 Mod 2
1
?2 Mod 2
0
?3 Mod 2
1

Comments or Responses

Login to post response