Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Function Optional parameter and default value

Status
Not open for further replies.

RottPaws

Programmer
Mar 1, 2002
478
US
I've got 3 different functions (vbscript) in my ASP page that do basically the same thing, but they have different parameters.

I'd like to make one function that has some optional parameters with defaults for the function to use if no value is passed for them.

How do I set this up?

Thanks in advance. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Here's a simple one. This function calls another function that creates a cell in a table, then it adds text to that cell and then calls another function that closes the cell.

I've got 2 of these. One is HTML_Grid_TD and this one is HTML_Grid_TD. The only difference is that this one takes a 2nd parameter to change the color of the text.

I'd like to make IN_Color an optional arguement that will default to black if no color is passed to the function.

Sub HTML_Grid_TD_Color(ByVal IN_Text, ByVal IN_Color)
HTML_Grid_TD_1
Response.Write &quot;<Font color=&quot;&quot;&quot;
Response.Write IN_Color
Response.Write &quot;&quot;&quot;>&quot;
Response.Write IN_Text
Response.Write &quot;</Font>&quot;
HTML_Grid_TD_2
End Sub

I've got more complicated ones with more arguements. That's a lot of duplicate code and any time I want to change something for those, I have to make the same change several times for each variation. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
AFAIK you can't build functions with optional parameters in ASP unlike Visual Basic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top