Visual Basic .NET Language Operators Assignment

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

There is a single assignment operator in VB.

  • The equal sign = is used both for equality comparison and assignment.
    Dim value = 5

Notes
Watch out for assignment vs. equality comparison.

Dim result = leftValue = rightValue  

In this example you can see the equal sign being used as both a comparison operator and an assignment operator, unlike other languages. In this case, result will be of type Boolean and will contain the value of the equality comparison between leftValue and rightValue.

Related: Using Option Strict On to declare variables properly



Got any Visual Basic .NET Language Question?