Functions usually have input and output, just like a factory, which sends in raw materials, processes them and sends out finished products.
For example, the following custom functions:
Returns factorial with a long integer as a parameter?
Private? Function? Fact (ByVal? part 1? As? Dragon) As? Dragon?
The truth? =? 1
What time? Part 1
The truth? =? The truth? *? Part 1
part 1? =? part 1? -? 1
line
End? The function calls this function: Print Fact(4), and the factorial result of 4 will be printed.
In this function, the formal parameter part 1 is the data to be processed, and the returned result is the processed data, that is, factorial-the function of this function.
VB library functions are the same as API functions, both of which encapsulate the code with a certain function for easy calling. We don't have to pay attention to its internal implementation, we just need to understand the interface.
2. As for parameters, they are not necessary for functions. For example:
Private? Function? Fac()
Me. Print? "output? Answer? String! "
Me. Print? "Do what? That? Best! "
End? function
Private? Sub? Form _ Click ()
Fac's calling function?
End? Sub this function is used to output specific content without parameters.
Function is a relatively basic thing, and learning it well is helpful to improve programming ability.