Add 2 number by Pass by Value method.
Refer the same program in normal programming code : Simple Programs(3) and Declare a function(Pass by reference)
Double click on Form and go to code window ( For Function)
Select Tools--> Add Procedure
Give Name - Add
Type - Function
Scope - Public
(E) Errors :
Taken from VB-Tutorial CDs ...
(A)Program Design :
(B) Property(Controls Used) :
- 3 Labels
- 3 TextBoxes
- One Command Button
Refer Simple Programs(3) to know the details about property.
(C) Attaching Code to the Object :
Private Sub Command1_Click() Dim first As Integer, second As Integer, answer As Integer First = Val(Text1.Text) Second = Val(Text2.Text) Answer = Add(First, Second) Text3.Text = Answer End Sub ------------------------------------------------------------------------------------------------ Public Function Add(a As Integer, b As Integer) As Integer Dim f As Integer f = a + b Add = f End Function |
Double click on Form and go to code window ( For Function)
Select Tools--> Add Procedure
Give Name - Add
Type - Function
Scope - Public
(E) Errors :
If found any errors while running your VB program, or want to put your comment about any program , please click Comment section , to post.
====================================================================
No comments:
Post a Comment