Calling options to make the program more efficient

Asked By 10 points N/A Posted on -
qa-featured

Hello!

I would like to learn how to call sub-procedure in Visual Basic? What is the use of “Call” keyword and what is the main purpose of this keyword? Can you help me create a program that will call sub procedure? How can I implement this in my program? Can you show me how to do this? Can you explain the syntaxes that we need to use for this program? What are the objects that we need to include in this program? Please provide me guidance. Thank you!

SHARE
Answered By 0 points N/A #175192

Calling options to make the program more efficient

qa-featured

Hello Angela!

It’s easy to implement and call functions or sub-functions. This usually implemented if you have to use the functions processes in a program for multiple time. This is for the benefit of making the program smaller and lessen lots of codes. I created a program that will illustrate how to implement this.

You just need the following.

1. Form 1 = you can manipulate this for or maybe add color.

2. 3 textboxes >> with name properties of strBox1, strBox2, strSum.

3. 1 Command button.

Here are the codes.

Public Class Form1

    Public Function add_values()

        intSum.Text = Val(intBox1.Text) + Val(intBox2.Text)

    End Function

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Call add_values()

    End Sub

End Class

The part that says Public Function add_values(), you have to type it manually. The user will be the one to define it. The “Call” just called and initiated the arithmetic operation – add. Notice that I placed the “Val” before the expression? We need to indicate it every because if not, it will only combine 1 and 2 that is equivalent to 12 not 3.

Related Questions