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

DCOM with ASP page

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
ve been attempting to get my head around VBScript with and working with dates. At the point of "computer go by by out of the window" decided to use a DCOM component to get my results.
Have created it and tested it.
I am familiar with database recordsets using VBSCRIPT but not getting two variables out of my function every time it loops around. The two variables are StartOfMonthOutput and MonthOutput. The function is shown below. Does anyone know how to get these two variables out of the DCOM as the program loops around.


Function Test(MonthsBack As Integer)

Dim counter As Integer
Dim PresentMonth As Integer
Dim DateWorkingWith As Date
DateWorkingWith = Date
Dim MonthOutput As Variant
Dim StartOfMonthOutput As Date
PresentMonth = Format(Date, "M")
counter = PresentMonth - MonthsBack
Do While counter <> PresentMonth
StartOfMonthOutput = DateSerial(Year(DateWorkingWith), Month(DateWorkingWith), 1)
MonthOutput = Format(StartOfMonthOutput, &quot;MMMM&quot;)
DateWorkingWith = DateAdd(&quot;M&quot;, -1, DateWorkingWith)
counter = counter + 1
Loop
End Function
 
Getting two variables out of a function could be accomplished by passing two variables in as arguments byRef, and then setting the value of those two variables before exiting the function.

Although this sounds more like the function of a subProcedure, than a function (where a function usually will take arguments and return a value, and a subprocedure usually either does work and/or modifies inputs), you could modify the function to work that way.

so:
Function Test(MonthsBack As Integer, byRef val1 AS variant, byRef val2 AS variant)

and then just set the value of those two before exiting for use in your ASP.

:)
paul
penny1.gif
penny1.gif
 
Paul it really needs to send data back to the ASP page on every loop. If you see there is a do while statement.
 
Well then I would suggest populating an array (or some other data object, custom recordset, perhaps) in the loop, and then returning that from the function.

Not going to be able to return something on each iteration of the loop. Only way to return a value is to exit the function, so you have to put the data somewhere, and then return the variable or object you decide to put it in.

paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top