default, as the program says I have to. Yet it doesn't pick up the default
value. Why is this, what am I doing wrong.
Public Function SelectQuery(strTbl as string, arr as ArrayList, Optional
SortCol as string = "Yr desc")
Calling procedure:
qry = SelectQuery(strTbl, arr, SortCol)You're passing SortCol in your calling procedure, so it wouldn't be
necessary (or desireable) for the optional portion to use the default value.
What happens with:
qry = SelectQuery(strTbl, arr)
"et" <eagletender2001@.yahoo.com> wrote in message
news:%23SKblAL$EHA.1396@.tk2msftngp13.phx.gbl...
>I have the following function that uses an optional parameter, and it sets
>a default, as the program says I have to. Yet it doesn't pick up the
>default value. Why is this, what am I doing wrong.
> Public Function SelectQuery(strTbl as string, arr as ArrayList, Optional
> SortCol as string = "Yr desc")
> Calling procedure:
> qry = SelectQuery(strTbl, arr, SortCol)
Et,
Ken gave you the right answer, but consider an alternative to use optional
parameters: overloading. So you end up with two SelectQuery functions:
public funciton SelectQuery(strTable as string, arr as ArrayList) as XXXX
return SelectQuery(strTable, arr, "Yr desc")
end function
Public Function SelectQuery(strTbl as string, arr as ArrayList, SortCol as
string ) AS XXX
...
end function
notice that the first function only has 2 parameters and simply calls the
2nd function with a default parameter. Both methods will work (optional or
overloading), but I prefer overloading...there has been some low level
technical debates about which is best, but I simply prefer it for
readability and the fact that optional parameters don't work in C# and I
like to keep my code as cross-language friendly as possible.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"et" <eagletender2001@.yahoo.com> wrote in message
news:%23SKblAL$EHA.1396@.tk2msftngp13.phx.gbl...
> I have the following function that uses an optional parameter, and it sets
a
> default, as the program says I have to. Yet it doesn't pick up the
default
> value. Why is this, what am I doing wrong.
> Public Function SelectQuery(strTbl as string, arr as ArrayList, Optional
> SortCol as string = "Yr desc")
> Calling procedure:
> qry = SelectQuery(strTbl, arr, SortCol)
0 comments:
Post a Comment