Argument ()

  • Thread starter Thread starter Klatuu
  • Start date Start date
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.
 
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.
 
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
 
can you please give me more explanation about the argument and the benefit
of using the argument and an easy example

Thank you
 
Back
Top