0rsted wrote:
Well, it's quite simple, it's easily done in C, but in ASP (and VB in
general) i haven't been able to see it done...
function setvalues(var1, var2="a", var3="b")
if var2="a" then
response.write("Var2 wasn't defined")
end if
if var3="b" then
response.write("Var3 wasn't defined")
end if
end function
I hope it makes sense, and that someone has the solution to it...
That's because it's not possible to assign default values for parameters in
the method declaration statements in vb/vbscript.
In VB, you can declare parameters using the Optional keyword, and use the
IsMissing method to test whether or not the arguments were supplied. This is
not the case in vbscript. Of course, given the fact that all variables are
Variant in vbscript, it's not something that can't be worked around:
<%
function setvalues(var1,var2,var3)
if len(var2)=0 then
response.write("Var2 wasn't defined")
end if
if len(var3)=0 then
response.write("Var3 wasn't defined")
end if
end function
setvalue 6
%>
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"