Skip to main content

VB Language

Comments

A comment is text in a VBA program that is ignored and has no effect on the program operation. You can (and should) use comments to document how the code works, provide details about procedure arguments, and add reminders to yourself or another programmer.

Comparison Operators

The comparison operators are used to perform comparisons between expressions. A comparison expression is actually a logical expression, evaluating to True or False depending on the data and operator used.

= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to

CSng()

This function will change a number into a single type.  A single type has 4 decimals so any decimals larger than 4 will be rounded to 4.

Date

The term date is used to refer to both dates and times.  Dates are represented numerically as floating-point numbers. The integer part of the number represents the date as the number of days since December 30, 1899 (with negative numbers for prior dates), and the fractional part of the number represents the time of day as a fraction of the 24-hour day.

DateDiff()

Syntax: DateDiff(Interval as String, Date1 as Date, Date2 as Date, Optional DayOfWeek, Optional WeekOfYear) as Long

Parameters:

Interval - There are 10 different types of intervals.  Depending on the interval the DateDiff() well return the number of units in the Interval.  Below is a list of the 10 items.  In the script below I used constants to better define them.

Parameter