473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Function return value

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
Nov 13 '05 #1
4 45114
bluedolphin wrote:
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


Private Function AddIT(I As Integer, J As Integer) As Integer
AddIt = I + J
End Function

Dim var As Variant
var = AddIt(1,2)
Msgbox Var

Assign the return value the name of the function.
Nov 13 '05 #2
I found the answer... Thanks though ...

In case anyone has the same question, the syntax is

Sub_Agg_Embedded_Catgeories = Sum_Point
Nov 13 '05 #3
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
Nov 13 '05 #4
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

if you want to assign the result of function call to intReturn, it's just:

intReturn=SomeFunction(arg1, arg2,...)

Oh, lemme guess... this looks a LOT like you're from the C/C++ world...

Sub ShowValueSomewhere()
Dim intPutReturnValueHere As Integer
Dim intUserValue as integer

intUserValue=cint(Inputbox("Please enter a number:"))
'--calls the TimesFive function and assigns the result to intPut...
intPutReturnVAlueHere=TimesFive(intUserValue)

End Sub
Function TimesFive(byval intInput as integer) As Integer
TimesFive=intInput * 5
End Function
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jonas | last post by:
Dear members, How can I use a function return value in a regexpr? $tmp=~s/mysearch/myfunction($1)/; sub myfunction { return $v; }
1
by: Tropos | last post by:
Query: Will a MutexGuard object release before a function return value is copied? Consider the C++ code: class MutexGuard //A familiar sort of class for making mutexes exception-safe { . ....
4
by: wongjoekmeu | last post by:
Hello All, I know that when you pass an argument to a function (if you want let the function be able to change the value) then you can choose to pass the argument by reference or a pointer to...
8
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on...
7
by: chellappa | last post by:
hi this program return value automatically ... how it is possible ..i am not return any value... but i return correct values i am using Linux -gcc complier please tell me what is this main() {...
11
by: randomtalk | last post by:
hi, i have the following recursive function (simplified to demonstrate the problem): >>> def reTest(bool): .... result = .... if not bool: .... reTest(True) .... else: .... print...
8
by: bdobby | last post by:
Hi. I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened... I have a form with an onsubmit event handler: <form id="uploadForm" method="post"...
4
by: pradeep | last post by:
Hello friends ~ We know that a C function will return a 32-bit value from a function in %eax and a 64-bit value in %edx:%eax. But what about larger return types, for example large structs? The...
6
by: kurt.krueckeberg | last post by:
Can someone explain why this line $bool = isset($_POST) && !empty(trim($_POST)); causes the error message "Can't use function return value in write context". trim() returns a string. I test if it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.