bc******@jeffco.k12.co.us (bluedolphin) wrote in message news:<37**************************@posting.google. com>...
This is my first function in Visual and I'm having a simple syntax
syntax issue that I'm hoping someone can help correct for me.
I have a function
Public Function Sub_Agg_Embedded_Catgeories(Pass_Report_Type_Desc As
String, other variables, ....) As Integer
I call it with the statement
intReturn = Sub_Agg_Embedded_Gender(Pass_Report_Type_Desc, other
variables)
when the function has completed, I want to Return a variable which is
called Sum_Points and have it assigned to intReturn.
Seems simple enough... At the end of the function I place
Return(Sum_Point) or Return Sum_Points ... and I get a syntax error of
"Expected end of statement"
What is the proper syntax for returning a single Integer to the
calling function in Visual?
Thanks in advance for your help.
BlueDolphin
Your call to your function, using
intReturn = Sub_Agg_Embedded_Gender(Pass_Report_Type_Desc, other
variables)
is how it's done. Your problem is within the function itself. If you
really want to return a variable called Sum_Point, then that's what
your function must be named (and your calling statement will need to
be changed), and within the function you must include the statement:
Sum_Point = (the result of the operations you've conducted on the
input variables)
In your case, you are already assigning the function's return value to
intReturn, but the function doesn't know what to return, since you
aren't assigning the result of the operations to the function. All
you need to do is include the statement:
Sub_Agg_Embedded_Gender = (the result of the operations you've
conducted on the input variables)
before the End Function line.
Note: if the function could return several possible values (eg. the
operations include IF statements), you would have several
Sub_Agg_Embedded_Gender = (something)
statements, possible with an
Exit Function
statement after each, depending on the actual structure of your IF
statements.
HTH,
Rob