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 shown prior, and afterward follow the accompanying focuses


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


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


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.