* (operator)

Syntax

expression1 * expression2

Description

Returns the product of expression1 and expression2.

Comments

The result is the same type as the most precise expression, with the following exceptions:

 

If one
expression is

and the other
expression is

then the type
the result is

 

Single

Long

Double

 

Boolean

Boolean

Integer

 

Date

Date

Double

 

When the * operator is used with variants, the following additional rules apply:

Empty is treated as 0.

If the type of the result is an Integer variant that overflows, then the result is automatically promoted to a Long variant.

If the type of the result is a Single, Long, or Date variant that overflows, then the result is automatically promoted to a Double variant.

If expression1 is Null and expression2 is Boolean, then the result is Empty. Otherwise, If either expression is Null, then the result is Null.

Example

This example assigns values to two variables and their product to a third variable, then displays the product of s# * t#.

Sub Main()
  s# = 123.55
  t# = 2.55
  u# = s# * t#
  MsgBox s# & " * " & t# & " = " & s# * t#
End Sub

See Also

Operator Precedence (topic)

More information

Symbols