ProgrammerGuide.Net | Step by Step Programmer Guide

VB-Logic

Logic,

Mod Operator
Syntax
result = number1 Mod number2
The Mod operator syntax has these parts:

PartDescription
resultRequired; any numeric variable.
number1Required; any numeric expression.
number2Required; any numeric expression.

Remarks
The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. For example, in the following expression, A (result) equals 5.
A = 19 Mod 6.7

Example:
Dim MyResult
MyResult = 10 Mod 5 ‘ Returns 0.
MyResult = 10 Mod 3 ‘ Returns 1.
MyResult = 12 Mod 4.3 ‘ Returns 0.
MyResult = 12.6 Mod 5 ‘ Returns 3.

And Operator
Used to perform a logical conjunction on two expressions.
Syntax
result = expression1 And expression2

The And operator syntax has these parts:

PartDescription
resultRequired; any numeric variable.
expression1Required; any expression.
expression2Required; any expression.

Remarks
If both expressions evaluate to True, result is True. If either expression evaluates to False, result is False. The following table illustrates how result is determined:

If expression1 is And expression2 is The result is

TrueTrueTrue
TrueFalseFalse
TrueNullNull
FalseTrueTrue
FalseFalseFalse
FalseNullFalse
NullTrueNull
NullFalseFalse
NullNullNull

Example:
Dim A, B, C, D, MyCheck
A = 10: B = 8: C = 6: D = Null ‘ Initialize variables.
MyCheck = A > B And B > C ‘ Returns True.
MyCheck = B > A And B > C ‘ Returns False.
MyCheck = A > B And B > D ‘ Returns Null.

Or Operator
Used to perform a logical disjunction on two expressions.
Syntax
result = expression1 Or expression2

The Or operator syntax has these parts:

PartDescription
resultRequired; any numeric variable.
expression1Required; any expression.
expression2Required; any expression.
Please click here for related products on Amazon!

Jayashee

Add comment

Want to Check Celebrities News?