Sunday, 13 October 2013

Example Program 1: add, subtract, multiply, division of 2 numbers and print them in TEXT BOXES using BUTTONS..

Example 1:


First insert 4 LABELS, 4 TEXT BOXES, 4 BUTTONS.
This is the FORM design.







Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim number1 As Integer = 100
        Dim number2 As Integer = 50

        Dim answer As Integer

        answer = number1 + number2
        TextBox1.Text = answer


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim number1 As Integer = 100
        Dim number2 As Integer = 50

        Dim answer As Integer

        answer = number1 - number2
        TextBox2.Text = answer

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim number1 As Integer = 100
        Dim number2 As Integer = 50

        Dim answer As Integer

        answer = number1 * number2
        TextBox3.Text = answer

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim number1 As Integer = 100
        Dim number2 As Integer = 50

        Dim answer As Integer

        answer = number1 / number2
        TextBox4.Text = answer

    End Sub
End Class


Then RUN the FORM.

we get the result as:



Then click on the buttons the result is:





  <---- Previous page                                     Next page ---->


VB.NET HOME PAGE