Writing the Equivalent of a C++ Function?

jazzscreamer

Registered User.
Local time
Today, 17:31
Joined
Mar 27, 2004
Messages
31
Hi,
I'm still a newbie when it comes to VB and VBA. I have coded in C++ for years and I was wondering what the correct way is to write code that can be reused by calling it in other parts of the program. What I'm talking about is just like a function in C++, but I don't know the correct way to do this in VB. Thank you for any help.

Joel
 
Last edited:
pseudo:

print myfunction("Hello")
Hello World!

-----------------
myfunction(mytxt as string) as string
myfunction = mytxt & " World!"
end function


???
ken
 
Thanks, I knew it had to be simple.
Joel
 
Joel,

To really be used in all of your forms, reports, queries, etc. put it in a
module (See the database tab).

Sample string function that adds a vbCrLf to end of argument:

Code:
Public Function SomeFunction(SomeArgument As String) As String
   SomeFunction = SomeArgument & vbCrLf
End Function

Wayne
 
While you are at it, try to not depend on functions of type "void", as VBA tends to want a data type for its functions.
 

Users who are viewing this thread

Back
Top Bottom