利用VB6.0随机生成20个100以内的正整数,将其中的奇数和偶数分两行显示...
发布网友
发布时间:2023-12-29 18:57
我来回答
共1个回答
热心网友
时间:2024-07-28 16:27
dim num1() as integer
dim num2() as integer
private function abc()
dim i as integer,j as integer,k as integer
dim temp as integer
randomize
do until i+j =20
temp = int((rnd*99)+1)
if temp mod 2 = 0 then
i = i+1
redim preserve num1(i)
num1(i) = temp
else
j = j+1
redim preserve num2(j)
num2(j) = temp
end if
loop
for k = 1 to i
print num1(k)
next
for k = 1 to j
print num2(k)
next
end function
时候时,在需要的地方调用abc,即可 如在按下按钮时:
private sub command1_click()
abc
end sub