Increment in Visual Basic .NET

Find this useful? Support us: Star on GitHub 6
Category: Number | Language: Visual Basic .NET

To increment a number in Visual Basic .NET, you can use the += operator. The += operator adds the value on the right-hand side to the variable on the left-hand side. Here's an example:

Dim myNumber As Integer = 5
myNumber += 1

In this example, myNumber starts with a value of 5. The += operator adds 1 to myNumber, so myNumber becomes 6.

You can also use the ++ operator to increment a number by 1. Here's an example:

Dim myNumber As Integer = 5
myNumber++

In this example, myNumber starts with a value of 5. The ++ operator adds 1 to myNumber, so myNumber becomes 6.

Alternatively, you can use the = operator to increment a number. Here's an example:

Dim myNumber As Integer = 5
myNumber = myNumber + 1

In this example, myNumber starts with a value of 5. The = operator assigns the sum of myNumber and 1 to myNumber, so myNumber becomes 6.

Note that all three of these methods increment the value of myNumber by 1.