VBA/Excel/Access/Word/Language Basics/Mathematical Operators

Материал из VB Эксперт
Версия от 12:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

any mathematical operation that can be performed on a number can be performed on a numerical variable

 
Sub Calculation()
    Dim num1 As Integer
    Dim num2 As Integer
    Dim answer As Integer
    num1 = 10
    num2 = 5
    answer = num1 + num2    " answer Holds 15
    answer = num1 - num2    " answer Holds 5
    answer = num1 * num2    " answer Holds 50
    answer = num1 / num2    " answer Holds 2
    answer = num1 ^ 2       " answer Holds 100
    answer = 2 ^ num2       " answer Holds 32
End Sub



Common Mathematical Operators Used in VBA

 
Operation           Operator
Addition            +
Subtraction         -
Multiplication      *
Division            /
Exponential         ^