Click to See Complete Forum and Search --> : calling a function from an asp page generate an error message


mpoincare
January 27th, 2003, 10:25 PM
I am trying to call a function that will generate a reference number
from an ASP Page. Here is the listing of the function:

function ReferenceNumber()
Dim Ref, tmpRef, weightTable
Randomize
Ref = Right(CStr(Day(Now)) & CStr(Month(Now)) & CStr(Second(Now) & CStr(Minute(Now)) & CStr(Year(Now)) & CStr(Int(Rnd * 1000))), 17)
i = Len(Ref)
weightTable = Array(7, 3, 1)
tmpRef = 0
n = 0
Do While i > 0
tmpRef = tmpRef + Mid(Ref, i, 1) * weightTable(n)
i = i - 1
n = n + 1
if n > 2 Then n = 0
Loop
tmpRef = Int(Left(tmpRef, Len(tmpRef) - 1) & "0") + 10 - tmpRef
ReferenceNumber = Ref & Right(tmpRef, 1)
End function
'To call the function: Ref=ReferenceNumber()
Whenever I call that function from an ASP page I get this error

message:
Technical Information (for support personnel)

Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/Plea/English/Invoice.asp, line 32, column 6
CodeC)
-----^
But the routine is not a Sub but a Function.
Can somebody explain me what that statement means in
a context like that and what can be done to fix it.

DeivaGanesh
January 27th, 2003, 11:09 PM
To my knowledge the code snippet u return is a sub-- just change the declaration and i am sure u will get it,,

Stephen Boston
January 28th, 2003, 02:47 PM
Well you state you are calling it like this
'To call the function: Ref=ReferenceNumber()

Change that to Ref=ReferenceNumber

This should correct that error.

HTH

Steve