-
upperbound and lowerbound represent the upper and lower bounds of a range, respectively, which is custom and can be changed.
upperbound - lowerbound represents the size of this range, and each number generated is contained in upperbound - lowerbound, but the int function int is used to round down, so you must add 1 to ensure that the maximum value of upperbound will occur.
Okay, now we have the maximum range (upperbound - lowerbound + 1), and then look at the random function rnd, this function can randomly appear any number between 0 and 1, so just use it to multiply it by the maximum range (upperbound - lowerbound + 1), you can have any number between 0 (upperbound - lowerbound + 1), plus lowerbound, This range becomes:
lowerbound (upperbound + 1), but the number in this range is still a decimal, so use the function int to round it down, and you can generate a random integer in the lowerbound upperbound range.
-
Let's say generate an integer between 5 and 10 with the formula:
int(rnd *6)+5
rnd generates decimals between 0 1, then rnd*6 = decimals between 0 6, but less than 6, so int(rnd*6) = an integer between 0 5, and then +5 = 5 10 integer.
-
1. The formula for the random number that produces the interval [a,b] in vb is: int((b- a+ 1) *rnd + a).
2. According to the above formula, it is impossible to generate random numbers in the range of (a, b] (half-open interval) by the formula method.
3. The rnd function returns a value less than 1 but greater than or equal to 0.
4. int is an integer function.
-
The answer is a
rnd returns a pure decimal in the range of [0,1), which can be taken as a value of 0, but not a value of 1, so the range of rnd*21 is [0,21), the range of rnd*21+30 is [30,51), and the range of int (rnd*21+30) is an integer between [30,50].
option explicit
private sub form_load()randomize >>>More
You can take a look at the function description in excel and try a few more times. >>>More
The generated file is located in the root directory of the D drive. >>>More
dim x as long 'New.
get #1, ,r2 'Read the record of R2 from the first point in channel 1; get 1, 2, r2 read the 2nd record of r2 from inside channel 1. >>>More
On the first floor, your method generates an array of controls that can't respond to events.