Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Operators and Expressions

Operators are symbols (characters or keywords) that specify operations to be performed on one or two operands (or arguments ). Operators that take one operand are called unary operators. Operators that take two operands are called binary operators. Unary operators use prefix notation , meaning that the operator precedes the operand (e.g., -5). Binary operators (except for one case) use infix notation , meaning that the operator is between the operands (e.g., 1 + 2). The TypeOf...Is operator is a binary operator that uses a special form that is neither prefix nor infix notation.

Unary Operators

Visual Basic supports the following unary operators:

+ (unary plus)

The unary plus operator takes any numeric operand. It’s not of much practical use because the value of the operation is equal to the value of the operand.

- (unary minus)

The unary minus operator takes any numeric operand (except as noted later). The value of the operation is the negative of the value of the operand. In other words, the result is calculated by subtracting the operand from zero. If the operand type is Short, Integer, or Long, and the value of the operand is the maximum negative value for that type, then applying the unary minus operator will cause a System.OverflowException error, as in the following code fragment:

Dim sh As Short = -32768
Dim i As Integer = -sh
Not (logical negation)

The logical negation operator takes a Boolean operand. The result is the logical negation of the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata