Saturday, July 20, 2013

Visual Basic Examples


Program 1:- To create Visual Basic application to find the area of rectangle.


Code:-
 Private Sub Command1_Click() Text3.Text = Text1.Text * Text2.Text End Sub

Private Sub Command2_Click()

Text1.Text = " " Text2.Text = " " Text3.Text = " " End Sub


/*************************Output**************************/





Program 2:- To create Visual Basic application to average of 3 numbers.
Design Window:-

Code:-

Private Sub Command1_Click()

Text4.Text = Str((Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3)

End Sub

Private Sub Command2_Click()

Text1.Text = " "

Text2.Text = " "

Text3.Text = " "

Text4.Text = " "

End Sub

Private Sub Command3_Click()

Unload Me

End Sub


/*************************Output**************************/



Program 3: To create Visual Basic application to illustrate Date-Time functions.

Code:-

Private Sub Command1_Click ()

Text1.Text = Date

Text2.Text = Time ()

Text3.Text = Year (Date)

Text4.Text = Month (Date)

End Sub

/*************************Output**************************/



Program 4:-To create Visual Basic application program to find maximum number among two numbers.

Code:-

Private Sub Command1_Click ()

Dim a As Integer

Dim b As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

If (a > b) Then

        Label3.Caption = "a is maximum number"

Else

        Label3.Caption = "b is maximum number"

End If

End Sub


/*************************Output**************************/

Program 5:-To create Visual Basic application program to perform arithmetic operations with the use of Option button.

Code:

Private Sub Option1_Click ()

Text3.Text = Val (Text1.Text) + Val (Text2.Text)

End Sub

Private Sub Option2_Click ()

Text3.Text = Val (Text1.Text) - Val (Text2.Text)

End Sub

Private Sub Option3_Click ()

Text3.Text = Val (Text1.Text) * Val (Text2.Text)

End Sub

Private Sub Option4_Click ()

Text3.Text = Val (Text1.Text) / Val (Text2.Text)

End Sub


/*************************Output**************************/



5 comments:

Featured posts

सौंफ के फायदे

 सौंफ त्रिदोषनाशक है, इसकी तासीर ठंडी है, पर यह जठराग्नि को मंद नहीं करती।            आंखों की रोशनी सौंफ का सेवन करके बढ़ाया जा सकता है। सौ...

Popular posts