O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The += and –= Operators and Their Relatives

Visual Basic provides abbreviation operators for numeric calculations, such as the += and –= operators, which add or subtract and assign values in one operation, and for string concatenations, the &= operator, which appends and assigns a string to another string in one operation. The following example (from the next section) shows how you would use +=:

Do
    If (helpValue And 1) = 1 Then
        resultValue += value1
    End If
    value1 = value1 << 1
    helpValue = helpValue >> 1
Loop Until helpValue = 0

There are other abbreviation operators in Visual Basic that work in much the same way. Table 1-2 shows these operators, along with a brief description:

Table 1-2. Operator Abbreviations in Visual Basic

Operation

Abbreviation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required