-
private sub command1_click()dim i as integer
dim sum as long
for i=1 to 10
sum=sum+fact(i)
sumend sub
function fact(x as integer) as long
if x=1 then
fact=1
elsefact=x*fact(x-1)
end if
end function
Although the structure is clear, it is computationally intensive, and it takes a total of 45 times to multiply factorial.
It can be changed to completely.
private sub command1_click()dim i as integer
dim jie as long
dim sum as long
jie=1for i=1 to 10
jie=jie*i
sum=sum+jie
sumend sub
This makes all factorials only need to be multiplied 10 times.
PS: Multiplication wastes a lot more CPU time than addition.
-
private sub command1 click()print lj(1, 100) 'call the function end sub
public function lj(byval aa as integer, bb as integer) 'accumulate custom functions.
for i = aa to bb
s = s + i
next i
lj = s
end function
-
function jiechengsum() as longdim sum as long
dim i as long
dim j as long
sum = 0
j = 1for i = 1 to 10
j = j * i
sum = sum + j
nextjiechengsum = sum
end function
Here's an example of a function being called.
private sub command1_click()msgbox jiechengsum
end sub
-
function(sum as integer,n as int)dim sum as integer
dim n as integer
dim i as integer
sum=0n=1i=1
for i=1 to 10
n=n*isum=sum+n
i=i+1next
That's about it, I forgot about it, hehe, try it, you can debug it again.
-
The custom function jc in the example above
Post this too.
-
What you're going to return, let's say a function is called: myf
Then set the return value to be written as (where you want to return):
myf=return value.
The return value can be changed.
-
Yes, the function name is the return value.
-
max=x
max=yvb does not need to be directly assigned.
-
Function: Specify a function The procedure can return a specific value.
A function is similar to a procedure, it is also a separate program used to complete a specific function**, it consists of a set of statements that conform to the VB syntax, it is different from a procedure in that the function can return a value to the caller, and the format of the custom function procedure is as follows:
publicl private][static]function, procedure name ([parametric table list]), [as type].
Definition of local variable constants.
Statement block" function name = return value.
exit function]
Function name = return value.
statement block] end function
Note: (1) Function and end function are the start and end flags of a function.
2) public: indicates that the function is "public", and private: indicates that the function is"Private"。
3) Parameter table column: variable name [as type] [, variable name [as type] ......
as type] is used to indicate the type of the return value of the function.
4) [exit function]: indicates the exit function process.
5) The method of building 1 function is the same as the process of building it.
-
The function keyword specifies a function that the procedure can return a specific value, such as:
public function yourneed(param as integer)as integer
yourneed=100
end function
The procedure returns a value of 100 at the end, e.g. a=yourneed(10), then a=100.
The sub procedure cannot return a value, such as:
public sub yourneed(param as integer)
yourneed=100'The statement here exists, but it is invalid.
end sub
When other procedures call the sub yourneed procedure, such as the a=yourneed(100) compiler, an error is reported.
-
print tab(10); string("characters",5);spc(6),chr(65),asc("a"),3 ; 4
tab(10) to position the cursor to column 10.
string("a",5);Output 5 characters "aaaaa".
spc(6), which outputs 6 spaces.
CHR(65) is given by the ASCII code.
asc("a"), there are characters to get ASCII codes.
There are many other functions that can be added to the pring statement as long as their result is a numeric value or a character.
-
。。The print function just prints out the string, and the related functions can be related to a wide range of functions. . . Includes all string functions... It can also be said that there is basically no function directly related to print...
There are many string functions, the commonly used ones are str, chr, trim, instr, replace... And many more.
-
private sub form_click()msgbox chengfa(3, 6) '18end sub
private function chengfa(a, b)chengfa = a * b
end function
Write a random one.
You can read it.
-
To be called or to define.
Call: direct p = functionname (parameter 1, parameter 2) definition: private function functionname (parameter 1, parameter 2).
Function body. functionname = a certain value.
end function
#include
#define m 5 >>>More
The first way: Replace Samsung i9000 system sound files.
Eliminate the sound of taking pictures with your own camera. >>>More
This generally has little to do with the configuration.,The configuration of the computer.,The ping is still very low when the network speed is on.,But it will be stuck.。 The network speed of the high-configuration computer is not good or not, this is generally affected by the bandwidth, the one you said should be called latency, it is a problem of network speed, you can consider increasing the network speed. When playing games, it's best to turn off the router login device that affects the network speed, and there should be no big problem if it is less than 100.
2. iOS, like Apple's Mac OS X operating system, belongs to the Unix-like commercial operating system. Originally, this system was called iPhone OS, because iPad, iPhone, iPod Touch all use iPhone OS, so the 2010 WWDC conference announced that it was renamed iOS
When the Straight Flush custom plate cannot be deleted, open the Straight Flush and click on the user plate settings in the toolbar to delete it. >>>More