Friend Function myFunct(ByVal Something As Something) As Something
Return Something
End Function
you first give the function a scope (in this case it's Friend but it could be Private, Protected, Public)
next you give it a name (myFunct is an example) then you declare the parameters it'll accept and how they'll be passed (ByVal/ByRef are how the data is passed, ByVal passes a copy whereas ByRef passes a pointer to the actual value(s)) and functions can accept Integers, Doubles, Singles, Chars, Decimals, Strings, etc... too
then lastly you declare what data type the function will be returning (String, Integer, Double, etc...)
then somewhere in the function you use the 'Return' keyword to actually return the value from the function
If the function was defined in the same file as the procedure, you would simply call it be name, passing the appropriate arguments:
myFunct(Something)
If the function had a return, you would need to assign it into something:
Dim myReturn as Something
myReturn=myFunct(Something)
If the function was defined in a seperate file, I usually keep all mine in a FunctionDefinitions.vb file, or an external DLL, you would include the assembly or enclosing class name:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.