如题所述
为了生成某个范围内的随机整数,可使用以下公式:
Int((upperbound
-
lowerbound
+
1)
*
Rnd
+
lowerbound)
upperbound
是随机数范围的上限,而
lowerbound
则是随机数范围的下限
Private
Sub
Command1_Click()
Dim
Rnd_Int
as
Integer
Randomize
Rnd_Int=Int(Rnd
*
401)
+
100
Print
Rnd_Int
End
Sub
Int((upperbound
-
lowerbound
+
1)
*
Rnd
+
lowerbound)
upperbound
是随机数范围的上限,而
lowerbound
则是随机数范围的下限
Private
Sub
Command1_Click()
Dim
Rnd_Int
as
Integer
Randomize
Rnd_Int=Int(Rnd
*
401)
+
100
Rnd_Int
End
Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答 2020-05-03
您好,这样的:
表达式如下:
Int((400
-
100
+
1)
*
Rnd
+
100)
【1】A$
=
Chr$(
Int(Rnd
*
10)
+
67)
【2】X=
Int(Rnd
*
101
+
100)
【3】If
x
*
y
>
0
Then
…
(x,y)位于I、III象限
【4】(x
mod
5)=
0
or
(x
mod
7)
=
0
【5】Y=(x
mod
10)*10
+
int(x/10)
(事先应保证x为2位数)
【6】X=(int(x*100))/100
【7】C
like
"[A-Z]"
or
C
Like
"[a-z]"
【8】C$
=
Mid(S,
5,
6)
【9】10
<=
x
and
x
<
20本回答被提问者采纳
表达式如下:
Int((400
-
100
+
1)
*
Rnd
+
100)
【1】A$
=
Chr$(
Int(Rnd
*
10)
+
67)
【2】X=
Int(Rnd
*
101
+
100)
【3】If
x
*
y
>
0
Then
…
(x,y)位于I、III象限
【4】(x
mod
5)=
0
or
(x
mod
7)
=
0
【5】Y=(x
mod
10)*10
+
int(x/10)
(事先应保证x为2位数)
【6】X=(int(x*100))/100
【7】C
like
"[A-Z]"
or
C
Like
"[a-z]"
【8】C$
=
Mid(S,
5,
6)
【9】10
<=
x
and
x
<
20本回答被提问者采纳
第2个回答 2019-03-25
vb.net
代码:运行test
sub
test()
dim
intout
as
intege
r‘定义整形变量存储随机数
dim
rnd
as
new
random
’定义随机生成器
intout
=
int(rnd.next(100,
200))
‘产生包含100的100至200的随机正整数
end
sub'==========================vb
6
代码:还是运行testsub
test()
dim
intout
as
integer
’定义整型变量存储随机数
intout
=
int(math.rnd
*
100)
+
100
‘生成包含100的100至200的随机数
end
sub
代码:运行test
sub
test()
dim
intout
as
intege
r‘定义整形变量存储随机数
dim
rnd
as
new
random
’定义随机生成器
intout
=
int(rnd.next(100,
200))
‘产生包含100的100至200的随机正整数
end
sub'==========================vb
6
代码:还是运行testsub
test()
dim
intout
as
integer
’定义整型变量存储随机数
intout
=
int(math.rnd
*
100)
+
100
‘生成包含100的100至200的随机数
end
sub