Home > Common Problem > Usage of Rnd function in VB

Usage of Rnd function in VB

angryTom
Release: 2020-02-07 15:07:46
Original
44469 people have browsed it

Usage of Rnd function in VB

Usage of Rnd function in VB

Rnd is a function that can generate double-precision random numbers between [0,1). int(N) is a function that takes the largest integer less than or equal to N, such as int(4.5)=4, int(-4.5)=5.

int(rnd usage method:

int(rnd * 范围 + 基数)
Copy after login

For example: int(rnd*m n) means to generate a random number between [n,m n-1]

Example: Suppose you want to store 6 randomly generated integers between 40 and 60 (including 40 and 60) into a one-dimensional array suijishu(). The statement is:

dim suijishu(1 to 6) as integer, i as integer
for i = 1 to 6
suijishu(i)=int(rnd*21+40)
next i
Copy after login

Analysis:

0<=rnd<1
0<=rnd*21<21
40<=rnd*21 40<61
40<=int( rnd*21 40)<=60

For more tutorials, please visit php中文网.

The above is the detailed content of Usage of Rnd function in VB. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template