Return Value (1 Viewer)

martijn

Registered User.
Local time
Today, 00:54
Joined
May 13, 2002
Messages
11
I want to make a function that gives a return value, but I don't know how to build one. Could someone help me?

Thanx and Greetz
 

simongallop

Registered User.
Local time
Today, 00:54
Joined
Oct 17, 2000
Messages
611
Not sure of what you want. If you want to carry out calculations on a field then:

Function MyStuff(TestData as ....)
''Carry out calculations then

TestData = Result of Calculations
End Function

What this does is the data being calculated is being passed to the function as variable TestData. When the function sees TestData = x it then returns x back to where it came from.

HTH
 

martijn

Registered User.
Local time
Today, 00:54
Joined
May 13, 2002
Messages
11
It's not what I mean.

In Delphi or C++ this is the body of the return function:

Funtion GiveFilename()
Return Filenaam
End Funtion

What the function has to do is return a private variable from a module class
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:54
Joined
Feb 19, 2002
Messages
43,550
The syntax in VBA is:

Funtion GiveFilename() as String
GiveFilename = Filenaam
End Funtion

It is always best to assign specific data types rather than using variants so I added the "as String". Then to set the value, you just use an equate statement in the form:

FunctionName = something
 

martijn

Registered User.
Local time
Today, 00:54
Joined
May 13, 2002
Messages
11
Thanx, that's what I needed!
=
 

Users who are viewing this thread

Top Bottom