关于VB数组的题,单击第一个按钮,生成20个【0,100】。。。。
关于VB数组的题,单击第一个按钮,生成20个【0,100】之间的随机整数,显示于文本框中,单击第二个按钮,求这20个随机整数中的最大数,并将其显示在另一个文本框中。请帮我...
关于VB数组的题,单击第一个按钮,生成20个【0,100】之间的随机整数,显示于文本框中,单击第二个按钮,求这20个随机整数中的最大数,并将其显示在另一个文本框中。
请帮我写一下代码,无比感谢 展开
请帮我写一下代码,无比感谢 展开
4个回答
展开全部
Dim a(20)
Private Sub Command1_Click()
Text1 = ""
Randomize
For i = 0 To 19
a(i) = Int(Rnd * 100)
Text1 = Text1 & a(i) & ","
Next i
End Sub
Private Sub Command2_Click()
Sum = a(0)
For i = 1 To 19
If a(i) > Sum Then
Sum = a(i)
End If
Next i
Text2 = Sum
End Sub
Private Sub Command1_Click()
Text1 = ""
Randomize
For i = 0 To 19
a(i) = Int(Rnd * 100)
Text1 = Text1 & a(i) & ","
Next i
End Sub
Private Sub Command2_Click()
Sum = a(0)
For i = 1 To 19
If a(i) > Sum Then
Sum = a(i)
End If
Next i
Text2 = Sum
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'Text1的multiline属性=True
dim a(19) as integer
private sub command1_click()
dim i as integer
randomize
for i=0 to 19
a(i)=int(rnd*101)
text1.text=text1.text & format(a(i),"@@@@@")
if (i+1) mod 5=0 then text1.text=text1.text & vbcrlf
next
end sub
private sub command2_click()
dim i as integer,max as integer
for i=0 to 19
if max<a(i) then max=a(i)
next
text2.text=max
end sub
dim a(19) as integer
private sub command1_click()
dim i as integer
randomize
for i=0 to 19
a(i)=int(rnd*101)
text1.text=text1.text & format(a(i),"@@@@@")
if (i+1) mod 5=0 then text1.text=text1.text & vbcrlf
next
end sub
private sub command2_click()
dim i as integer,max as integer
for i=0 to 19
if max<a(i) then max=a(i)
next
text2.text=max
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim A(19) As Integer, i As Integer
Private Sub Command1_Click()
Randomize Timer ' 对随机数生成器做初始化的动作
For i = 0 To 19
A(i) = Rnd * 101
Text1 =text1 & A(i) & ","
Next
End Sub
Private Sub Command2_Click()
Dim max As Integer
For i = 0 To 19
If max < A(i) Then max = A(i)
Next
text2 = max
End Sub
Private Sub Command1_Click()
Randomize Timer ' 对随机数生成器做初始化的动作
For i = 0 To 19
A(i) = Rnd * 101
Text1 =text1 & A(i) & ","
Next
End Sub
Private Sub Command2_Click()
Dim max As Integer
For i = 0 To 19
If max < A(i) Then max = A(i)
Next
text2 = max
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
上面几位的代码都不错,不过要显示全部内容,最好把Text文本框拉大,否则无法全部显示。其实在窗体上显示更好,你可以试试。
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询