Ratakan

Informations :

Arithmetic Operators in Visual Basic VB.NET

Arithmetic Operators in Visual Basic VB.NET

What are all the Arithmetic Operators in Visual Basic VB.NET?

Explanation

Arithmetic Operators in Visual Basic VB.NET

Operators used for basic arithmetic operations like addition, subtraction, multiplication, division, are known as Arithmetic Operators.
Following table lists the Arithmetic Operators used in Visual Basic.
OperatorDescription
^Exponentiation Operator
*Multiplication Operator
/Division Operator
Integer division Operator
ModModulus Operator
+Unary and Binary Addition Operator
-Unary and Binary Negation Operator
Example:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button3.Click
TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button4.Click
TextBox6.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button5.Click
TextBox7.Text = Val(TextBox1.Text) Val(TextBox2.Text)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button6.Click
TextBox8.Text = Val(TextBox1.Text) Mod Val(TextBox2.Text)
End Sub End Class
Description:

In the above example, we use two text boxes TextBox1 and TextBox2 to get the operands for performing arithmetic operations by clicking on appropriate operator buttons.

No comments