'添加窗体Form1,按钮Command1,然后添加如下代码:
Private Sub Command1_Click()
Dim a(9), i, temp As Integer
For i = 0 To 9
a(i) = Val(InputBox("请输入第" & i + 1 & "个数:"))
Next
temp = a(0)
For i = 0 To 9
If a(i) > temp Then temp = a(i)
Next
Print "最大数为:" & temp
End Sub
'添加窗体Form1,按钮Command1,然后添加如下代码:
Private Sub Command1_Click()
Dim temp As String
Dim i As Integer
Dim a(9) As Integer
For i = 0 To 9
Randomize
a(i) = Int(Rnd * 100)
Print a(i);
Next
temp = a(0)
For i = 0 To 9
If a(i) > temp Then temp = a(i)
Next
Print "最大数为:" & temp
End Sub
把10个数存入数组.
dim a(1 to 10) as integer,nMax%,i%
'产生10个数
for i=1 to 10
a(i)=int(Rnd*100)
next i
nmax=a(1)
for i=1 to 10
if a(i)>nmax then nmax=a(i)
next i
print nmax