给你个例子
专注于为中小企业提供网站制作、成都网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业万荣免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
'生成20个随机整数
Dim MyRandom As New Random
Dim a(19), b() As Integer
For i = 0 To a.GetUpperBound(0)
a(i) = MyRandom.Next(0, 1001)
Next
b = a.Clone '复制数组
'排序
System.Array.Sort(b)
System.Array.Reverse(b)
数组b是结果
用不到2个命令按钮 1个就够
在按钮的过程中写如下代码
dim x as long , y as long ,z as long ,j as long ,n as long
dim k as integer
x = val(text1.text)
y = val(text2.text)
z = val(text3.text)
j = val(text4.text)
if x = then k = k+1
if y= then k = k+1
if z= then k = k+1
if j= then k = k+1
' 若输入的数有负数 则必须先在这里写下 n=-.....()
do
if x 0 and n = x then
text5.text = text5.text " " x
k = k +1
end if
if y 0 and n = then
text5.text = text5.text " " y
k = k +1
end if
if z 0 and n = z then
text5.text = text5.text " " z
k = k +1
end if
if j 0 and n = j then
text5.text = text.text " " j
k = k +1
end if
if k = 4 then exit for
n=n+1
loop
这是VB的代码。。。。 不知道点虐 适用不
'给数组赋值
dim d(6) as integer
d(1)=11
d(2)=32
d(3)=25
d(4)=45
d(5)=9
d(6)=5
'获取最大值(采用打擂台的思路)
dim MyMax as integer
dim i as integer
MyMax = d(1) '假设第1个元素最大
for i = 2 To Ubound(d) '从第2个元素开始到最后一个元素
'如果当前元素比MyMax的值大,就把当前元素保存到MyMax
if d(i) MyMax Then
MyMax = d(i)
end if
next i
msgbox MyMax