' Visual Basic 2008 9.0 .NET Examples - Operators - Introduction to Visual Basic : Module Example9 Sub Main() Dim value As Integer Dim position As Integer Dim counter As Integer Dim start As Integer ' value = 12 position = 1 Do While (value And 1) = 0 ' (1) value >>= 1 position += 1 Loop Console.WriteLine("12 : Bit at position " & position & _ " from the right is 1.") ' value = 12 position = 1 Do While value Mod 2 <> 1 ' (2) value /= 2 position += 1 Loop Console.WriteLine("12 : Bit at position " & position & _ " from the right is 1.") ' start = Environment.TickCount() For counter = 1 To 10000000 ' (3) value = counter position = 0 ' Do While (value And 1) = 0 ' (1) value >>= 1 position += 1 Loop Next Console.WriteLine("Bitwise calculation done in " & _ Environment.TickCount() - start & " tickcounts.") ' start = Environment.TickCount() For counter = 1 To 10000000 ' (3) value = counter position = 0 ' Do While value Mod 2 <> 1 ' (2) value /= 2 position += 1 Loop Next Console.WriteLine("Normal calculation done in " & _ Environment.TickCount() - start & " tickcounts.") ' Console.ReadLine() End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.