'Visual Basic 2008/2010 Bitshift Operatoren Operatoren Module Example2 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 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.