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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Overloading

Status
Not open for further replies.

macr0

Programmer
Jan 29, 2000
31
US
Is there a way to overload a VBScript function? Take the following example:<br><br>definition:<br><br>Function MakeConn(strSql, x, y)<br>Dim ConnTemp, RsTemp<br><br>Set ConnTemp = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>Set RsTemp = Server.CreateObject(&quot;ADODB.Recordset&quot;)<br><br>ConnTemp.Open &quot;PROVIDER = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Inetpub\ strSql, ConnTemp, x, y<br><br>MakeConn = RsTemp<br><br>End Function<br><br>instance:<br><br>Dim objCool<br>set objCool = MakeConn(&quot;select * from address&quot;,1, 2)<br>Response.Write &quot;&lt;br&gt;&quot; & objCool(&quot;Email&quot;)<br><br>--------------------------------------------------<br>This works fine the way it is, however I would like to be able to do this:<br><br>set objCool = MakeConn(&quot;select * from whatever&quot;)<br><br>and have default values of 0 and 2 for x and y respectively. How very easy it is to do such in C++!<br><br>Thanks<br>Jeremy Lowery
 
Dear Macr0,<br><br>I'm not really a VB person but I know the compiler supports optional parameters. So if the latest scripting engine does you could make (x and y) optional and supply default values in the function if the user doesn't supply them as parameters. Sorry I don't know the exact keyword and syntax.<br><br>Good Luck<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top