Referencing Function Arguments

B

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.
 
G

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
 
B

Brian Tkatch

GhostInAK said:
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

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.
 
G

GhostInAK

Hello Brian,

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


-Boo
 

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

Similar Threads


Top