﻿'Visual Basic 2012 Samengestelde Toekennings Operatoren Operatoren Module CompoundAssignmentOperatorsExample1 Sub Main() Dim value As Integer = 2 ' value *= 3 + 4 ' (1) ' Console.WriteLine(value) ' Console.ReadLine() End Sub End Module Module CompoundAssignmentOperatorsExample2 Sub Main() Dim message As String = "Hello" ' message &= " World !" ' Console.WriteLine(message) ' Console.ReadLine() End Sub End Module Module CompoundAssignmentOperatorsExercise Sub Main() Dim value1, value2, value3 As Integer ' value1 += 5 value2 -= value1 * 6 + 1 value3 += value1 + 5 * value2 value3 *= value3 / -3 value1 /= 1 / (value2 + 41) value2 \= 10 + value1 / 5 ' Console.WriteLine(value1) ' ? Console.WriteLine(value2) ' ? Console.WriteLine(value3) ' ? ' Console.ReadLine() End Sub End Module Module CompoundAssignmentOperatorsSolution Sub Main() Dim value1, value2, value3 As Integer ' value1 += 5 ' value1 = value1 + 5 ' = 0 + 5 ' = 5 value2 -= value1 * 6 + 1 ' value2 = value2 - (value1 * 6 + 1) ' = 0 - (5 * 6 + 1) ' = 0 - (30 + 1) ' = -31 value3 += value1 + 5 * value2 ' value3 = value3 + (value1 + 5 * value2) ' = 0 + (5 + 5 * -31) ' = 0 + (5 + -155) ' = 0 + -150 = -150 value3 *= value3 / -3 ' value3 = value3 * (value3 / -3) ' = -150 * (-150 / -3) ' = -150 * 50 ' = -7500 value1 /= 1 / (value2 + 41) ' value1 = value1 / (1 / (value2 + 41)) ' = 5 / (1 / (-31 + 41)) ' = 5 / (1 / 10) ' = 50 value2 \= 10 + value1 / 5 ' value2 = value2 \ (10 + value1 / 5) ' = -31 \ (10 + 50 / 5) ' = -31 \ (10 + 10) ' = -31 \ 20 ' = -1 ' Console.WriteLine(value1) ' 50 Console.WriteLine(value2) ' -1 Console.WriteLine(value3) ' -7500 ' Console.ReadLine() End Sub End Module 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2012 - Alle rechten voorbehouden.