- Home
- Visaul Basic And VB.NET
- VB operators And Commands
VB operators And Commands
- By Mike Tayler
- Published 03/24/2007
- Visaul Basic And VB.NET
- Unrated
Mike Tayler
View all articles by Mike Tayler
/ - Normal division
\ - Integer division (truncates the answer)
^ - Exponentiation operator
* - Multiply
+ - Plus
- - Minus
= - Equal
> - Greater Than
< - Less Than
<> - Not Equal
>= - Greater than or equal
<= - Less than or equal
AND - Defines a boolean value that is the AND of two values
result = expression1 AND expression2
OR - Defines a boolean value that is the OR of two values
result = expression1 OR expression2
XOR - Defines a boolean value that is the exclusive OR of two values
result = expression1 XOR expression2
NOT - Defines an opposite boolean value
A = NOT B
EQV - Performs a logical equivalence on two expressions (result is true if both expressions are true)
result = expression1 EQV expression2
IMP - Performs a logical implication on two expressions
result = expression1 IMP expression2
IS - Determines if 2 variables reference the same object
result = object1 IS object2
LIKE - Determines if one string matches a pattern
result = string LIKE pattern
MOD - Returns the integer remainder of a division
i = 27 MOD 5
Math
VB also provides built-in functions which can act on variables. Most are self-explanatory. In my experience, the VAL, RND, and ROUND functions are among the most valuable, so be sure to pay close attention to them!
Round - Rounds a number to a selectable number of decimal places
result = round ( tempvariable,2 )
Val - Returns the numerical content of a string
result = Val ("123.4")
Int - Returns an integer by truncating (different than Fix)
i = int ( tempvariable )
Fix - Returns an integer by truncating (different than Int)
i = fix ( tempvariable )
Hex - Returns the hexadecimal value of any number
temp$ = hex ( tempvariable )
Oct - Returns the octal value of any number
temp$ = oct ( tempvariable )
Tan - Returns the tangent of an angle
tempvariable1 = tan ( tempvariable2 )
Rnd - Returns a random number between 0 and 1
tempvariable1 = rnd
Randomize - Initializes the Rnd function so it gives different answers each time

