-
There are return and result processing parameters. Don't you know?
-
There are two ways to pass values from subroutines.
1) Make use of module-level or global variables. For example.
option explicit
r is a module-level variable.
dim r as integer
sub add(byval x as integer, byval y as integer)
Store the results of the calculation to r
r = x + y
end sub
private sub form_click()'Call the subroutine add
call add(10, 20)
Get the calculation results and print them.
print r
end sub
2) Use the byref parameter to implement the return of the calculation results. For example, option explicit
The add subroutine uses byref r as integer to return the value sub add(byref r as integer, byval x as integer, byval y as integer).
r = x + y
end sub
private sub form_click()dim r as integer
The subroutine add is called, and the result is passed back to the variable rcall add(r, 10, 20).
Print the results. print r
end sub
-
function aaaa() as integer
aaa=2 'This is the return value, i.e. the function name on the left, and the value you want to return on the right.
end function
-
The parameters of the functions in VB are addressed by default, which means that the changes in the parameters in the main program in the sub-program will be reflected in the main program, and the return value of the function can also be used to make the main program obtain the value generated in the sub-program.
-
There are two types of parameters for subroutines of VB:
The keyword byval is declared as a pass parameter.
The address parameter is declared with the keyword byref.
For example, the subroutine aaaa:
sub aaaa(vyval a as integer,byref b as integer)
a=99b=100
end sub
Now go and call it as follows:
dim x as integer,y as integerx=1y=2
print x,y
aaaa x,y
print x,y
Yes, we can see that the output is the same for x and different for y.
y passed the result of the subroutine to the other.
Of course, writing a function can pass the result, but the function name can only pass one result, while using byref can pass multiple results.
-
If the subprogram you write is a function, you're fine.
For example: function say(byval s as string)msgbox s
say="ok"
end function
Two commandbuttons, two lables, two texts"
private sub command1_click()r = >>>More
dim i, j as boolean
i = false >>>More
You can consider writing binary data, binary mode open**, adodb can use [variable] to write binary data, data control should also be possible, but I can't remember it. However, if you use the data control, you can be lazy to display **: bind the field property of a visible=false picturebox to the field property and output it directly, and then it is very convenient. >>>More
I tried going downstairs with no problem. If it can't be opened, the landlord can try this sentence: (note that it is 3 quotation marks). >>>More
Revised at 22:25 on March 8.
1. First make a word document, draw a ** in it, one grid per line, put the text of the title and ** in the same grid, one line per question, do not leave blank lines, and then save it in the project directory and name it "Title." doc”; >>>More