VBA Arithmetic Operators - Shikshaglobe

Content Creator: Vijay Kumar

VBA Arithmetic Operators

VBA Arithmetic Operators are utilized to perform math tasks, for example, adding, deducting, partitioning, or increasing numbers.

The accompanying table shows the VBA numerical administrators


VBA Arithmetic Operators Example

Add a button to the Excel sheet as we were shown prior, and afterward follow the accompanying focuses

1.     Addition Operator (+):

·         The addition operator (+) is used to add two or more values together.

·         Example: result = num1 + num2

2.     Subtraction Operator (-):

·         The subtraction operator (-) is used to subtract one value from another.

·         Example: result = num1 - num2

3.     Multiplication Operator (*):

·         The multiplication operator (*) is used to multiply values.

·         Example: result = num1 * num2

4.     Division Operator (/):

·         The division operator (/) is used to divide one value by another.

·         Example: result = num1 / num2

5.     Integer Division Operator ():

·         The integer division operator () performs division and rounds down the result to the nearest integer.

·         Example: result = num1 \ num2

Nursery Teacher Training

6.     Modulus Operator (Mod):

·         The modulus operator (Mod) calculates the remainder when one value is divided by another.

·         Example: result = num1 Mod num2

7.     Exponentiation Operator (^):

·         The exponentiation operator (^) raises one value to the power of another.

·         Example: result = num1 ^ num2

VBA Operators

Change the name property to btnAdd

Change the inscription property to Add Operator

Right snap on the button

Select view code

You will get the accompanying code window

VBA Operators

Enter the accompanying in the middle of between Private Sub btnAdd_Click() and End Sub

Find out more

Faint x As Integer, z As Integer

x = 2

z = 3

MsgBox x + z, vbOKOnly, "Expansion Operator"

Click on the save button

Close the code proofreader window

We should now execute our code

Experience the difference

On the lace bar, search for the button Design Mode


On the off chance that the button is in a dynamic state (green foundation tone), it's in plan mode. You can't execute code in this state. In the event that it isn't in the dynamic state (white foundation tone), then, at that point, it permits you to run the code.

Click on the Design Mode button

The button ought to now show up as follows

Click on Add administrator

You will obtain the accompanying outcomes

Download the above Excel Code

Math Operators Tutorial activity

The most effective way to learn is by rehearsing. Follow the above moves toward making buttons for the deduction, division, increase, and exponentiation.

Compose the code so that the buttons and test them might be able to check whether the code executes.

See also here -->>

Read More :

What are the Main Objectives of Project Management
Web Scraping with VBA
How to Debug Mappings in Informatica
Mappings in Informatica

Featured Universities

Mahatma Gandhi University

Location: Soreng ,Sikkim , India
Approved: UGC
Course Offered: UG and PG

MATS University

Location: Raipur, Chhattisgarh, India
Approved: UGC
Course Offered: UG and PG

Kalinga University

Location: Raipur, Chhattisgarh,India
Approved: UGC
Course Offered: UG and PG

Vinayaka Missions Sikkim University

Location: Gangtok, Sikkim, India
Approved: UGC
Course Offered: UG and PG

Sabarmati University

Location: Ahmedabad, Gujarat, India
Approved: UGC
Course Offered: UG and PG

Arni University

Location: Tanda, Himachal Pradesh, India.
Approved: UGC
Course Offered: UG and PG

Capital University

Location: Jhumri Telaiya Jharkhand,India
Approved: UGC
Course Offered: UG and PG

Glocal University

Location: Saharanpur, UP, India.
Approved: UGC
Course Offered: UG and PG

Himalayan Garhwal University

Location: PG, Uttarakhand, India
Approved: UGC
Course Offered: UG and PG

Sikkim Professional University

Location: Sikkim, India
Approved: UGC
Course Offered: UG and PG

North East Frontier Technical University

Location: Aalo, AP ,India
Approved: UGC
Course Offered: UG and PG