vb编程题 窗体上有一个名称为command1的命令按钮和名称为text1和text2的两个文本框,当窗体加载时在text1中
当窗体加载时在text1中显示随机产生的10个10~99之间的随机整数,当单击command1命令按钮时,在text2中显示对这10个随机整数由大到小或者由小到大的排序结...
当窗体加载时在text1中显示随机产生的10个10~99之间的随机整数,当单击command1命令按钮时,在text2中显示对这10个随机整数由大到小或者由小到大的排序结果。 所以 这也算是两个题 谢谢啦
展开
3个回答
2012-12-20
展开全部
Dim a(1 To 10) As Integer
Private Sub Command1_Click()
For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then
b = a(i): a(i) = a(j): a(j) = b
End If
Next j
Next i
Text2.Text = ""
For i = 1 To 10
Text2 = Text2 & Str(a(i))
Next i
End Sub
Private Sub Form_Load()
Randomize
Text1.Text = ""
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
Text1 = Text1 & Str(a(i))
Next i
End Sub
Private Sub Command1_Click()
For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then
b = a(i): a(i) = a(j): a(j) = b
End If
Next j
Next i
Text2.Text = ""
For i = 1 To 10
Text2 = Text2 & Str(a(i))
Next i
End Sub
Private Sub Form_Load()
Randomize
Text1.Text = ""
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
Text1 = Text1 & Str(a(i))
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option ExplicitDim s(9) As Long
Private Sub Command1_Click()
Dim i As Long
For i = 1 To 9
PaiXu i
Next
Text2.Text = ""
For i = 0 To 9
Text2.Text = Text2.Text & s(i) & ","
Next
End Sub
Private Sub Form_Load()
Dim i As Long
Text1 = ""
Text2.Text = ""
Randomize
For i = 0 To 9
s(i) = Fix(Rnd() * 90 + 10)
Text1.Text = Text1.Text & s(i) & ","
Next
End Sub
Public Sub MaxS(a As Long, b As Long)
Dim c As Long
If b < a Then
c = a
a = b
b = c
End If
End Sub
Public Sub PaiXu(n As Long)
Dim i As Long
DoEvents
If n < 0 Or n > 8 Then Exit Sub
MaxS s(n), s(n + 1)
PaiXu n - 1
End Sub
Private Sub Command1_Click()
Dim i As Long
For i = 1 To 9
PaiXu i
Next
Text2.Text = ""
For i = 0 To 9
Text2.Text = Text2.Text & s(i) & ","
Next
End Sub
Private Sub Form_Load()
Dim i As Long
Text1 = ""
Text2.Text = ""
Randomize
For i = 0 To 9
s(i) = Fix(Rnd() * 90 + 10)
Text1.Text = Text1.Text & s(i) & ","
Next
End Sub
Public Sub MaxS(a As Long, b As Long)
Dim c As Long
If b < a Then
c = a
a = b
b = c
End If
End Sub
Public Sub PaiXu(n As Long)
Dim i As Long
DoEvents
If n < 0 Or n > 8 Then Exit Sub
MaxS s(n), s(n + 1)
PaiXu n - 1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询