Self Assignment
It is very common to increment a variable and store the result back in the variable itself.
value = value + 3
VB.NET allows you to use shortcut notation known as "self assignment".
value += 1 'value = value + 1
value -+ 2 'value = value - 2
value *= 3 'value = value * 3
value /= 4 'value = value / 4
value \= 5 'value = value \ 5
You can also use self assignment with strings
string = "some"
string += "text" 'string = string & "text"
(You cannot use string &- "text"
+= operator returns a value as well as assigning the value
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext