Home All Groups Group Topic Archive Search About

Referencing Function Arguments

Author
14 Jun 2006 8:50 PM
Brian Tkatch
Is there a way to reference an argument to a function without using its
name?

Something like:

Public Function MyFunc(ByVal Arg1 As String, ByVal Arg2 As String) As
String

  MsgBox(MyFunc.Arguments(1).Value)
  MsgBox(MyFunc.Arguments(2).Value)

End Function

B.

Author
14 Jun 2006 9:00 PM
GhostInAK
Hello Brian,

Yes.. but it's not good practice.  You can declare a parameter as a ParamArray
(look it up in the help docs).  But it would be best to just pass an array,
like:

public sub SomeFunction(byval tArray() as string)
Dim tIndex as integer=0

for tIndex=tArray.GetLowerBounds(0) To tArray.GetUpperBounds(0)
msgbox(tArray(tIndex)
next
end sub

-Boo

Show quoteHide quote
> Is there a way to reference an argument to a function without using
> its name?
>
> Something like:
>
> Public Function MyFunc(ByVal Arg1 As String, ByVal Arg2 As String) As
> String
>
> MsgBox(MyFunc.Arguments(1).Value)
> MsgBox(MyFunc.Arguments(2).Value)
> End Function
>
> B.
>
Author
15 Jun 2006 2:49 PM
Brian Tkatch
GhostInAK wrote:
Show quoteHide quote
> Hello Brian,
>
> Yes.. but it's not good practice.  You can declare a parameter as a ParamArray
> (look it up in the help docs).  But it would be best to just pass an array,
> like:
>
> public sub SomeFunction(byval tArray() as string)
> Dim tIndex as integer=0
>
> for tIndex=tArray.GetLowerBounds(0) To tArray.GetUpperBounds(0)
> msgbox(tArray(tIndex)
> next
> end sub
>
> -Boo
>
> > Is there a way to reference an argument to a function without using
> > its name?
> >
> > Something like:
> >
> > Public Function MyFunc(ByVal Arg1 As String, ByVal Arg2 As String) As
> > String
> >
> > MsgBox(MyFunc.Arguments(1).Value)
> > MsgBox(MyFunc.Arguments(2).Value)
> > End Function
> >
> > B.
> >

Thanx,

Actually, i do not want to pass an array at all. It is important that
the definition of the function's arguments be exact.

B.
Author
15 Jun 2006 7:52 PM
GhostInAK
Hello Brian,

Then no.  Having written the function you should know the parameters' names.


-Boo

Show quoteHide quote
> GhostInAK wrote:
>
>> Hello Brian,
>>
>> Yes.. but it's not good practice.  You can declare a parameter as a
>> ParamArray (look it up in the help docs).  But it would be best to
>> just pass an array, like:
>>
>> public sub SomeFunction(byval tArray() as string)
>> Dim tIndex as integer=0
>> for tIndex=tArray.GetLowerBounds(0) To tArray.GetUpperBounds(0)
>> msgbox(tArray(tIndex)
>> next
>> end sub
>> -Boo
>>
>>> Is there a way to reference an argument to a function without using
>>> its name?
>>>
>>> Something like:
>>>
>>> Public Function MyFunc(ByVal Arg1 As String, ByVal Arg2 As String)
>>> As String
>>>
>>> MsgBox(MyFunc.Arguments(1).Value)
>>> MsgBox(MyFunc.Arguments(2).Value)
>>> End Function
>>> B.
>>>
> Thanx,
>
> Actually, i do not want to pass an array at all. It is important that
> the definition of the function's arguments be exact.
>
> B.
>
Author
16 Jun 2006 6:37 PM
Brian Tkatch
GhostInAK wrote:
Show quoteHide quote
> Hello Brian,
>
> Then no.  Having written the function you should know the parameters' names.
>
>
> -Boo
>
> > GhostInAK wrote:
> >
> >> Hello Brian,
> >>
> >> Yes.. but it's not good practice.  You can declare a parameter as a
> >> ParamArray (look it up in the help docs).  But it would be best to
> >> just pass an array, like:
> >>
> >> public sub SomeFunction(byval tArray() as string)
> >> Dim tIndex as integer=0
> >> for tIndex=tArray.GetLowerBounds(0) To tArray.GetUpperBounds(0)
> >> msgbox(tArray(tIndex)
> >> next
> >> end sub
> >> -Boo
> >>
> >>> Is there a way to reference an argument to a function without using
> >>> its name?
> >>>
> >>> Something like:
> >>>
> >>> Public Function MyFunc(ByVal Arg1 As String, ByVal Arg2 As String)
> >>> As String
> >>>
> >>> MsgBox(MyFunc.Arguments(1).Value)
> >>> MsgBox(MyFunc.Arguments(2).Value)
> >>> End Function
> >>> B.
> >>>
> > Thanx,
> >
> > Actually, i do not want to pass an array at all. It is important that
> > the definition of the function's arguments be exact.
> >
> > B.
> >

Thanx for responding.

B.