Argument ()

K

Klatuu

Then parentheses () are always required in the definition of a sub or function.
Those items in the parentheses are arguments the sub or function needs to
complete its task.
 
K

Klatuu

You need arguments for subs or functions when you want the sub or function to
use a value in its processing. For example, you want a function to return a
value based on a value in an control on a form. In this example, you want to
return the name of a color depending on a number you pass it.

Function GetColor(lngColor As Long) As String
Select Case lngColor
Case 1
GetColor = "Red"
Case 2
GetColor = "Yellow"
Case 3
GetColor = "Blue"
End Select
End Function

You would call it like:

strColor = GetColor(Me.txtColorCode)

it will return one of the colors in the list and put it in the variable
strColor.
 
A

a

thank you

===================================

Private Sub Form_BeforeInsert(Cancel As Integer)

===================================

help me to know any information about the ( ) beside the name of the
procedure how can I understand the benefit of using this ( ) and when should
I put entry in ()

Any help or information thank you
 
A

a

can you please give me more explanation about the argument and the benefit
of using the argument and an easy example

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top