请老师帮我做两道vb编程题.1、编程实现对100个整数的排序。2、请编程实现每两秒在标签中显示一次当前的时
只要能完成指定的功能,界面怎么设计都行。也就是说,界面如何以及代码写在哪个事件中都没关系,前提是必须保证完成相应的功能。请老板务必在周五前给我详细答案,我急用。谢谢老师!...
只要能完成指定的功能,界面怎么设计都行。也就是说,界面如何以及代码写在哪个事件中都没关系,前提是必须保证完成相应的功能。
请老板务必在周五前给我详细答案,我急用。谢谢老师!! 展开
请老板务必在周五前给我详细答案,我急用。谢谢老师!! 展开
2个回答
展开全部
1题
Private Sub Form_Click()
'随机生成100个整数(本程序中整数数值设为10000以内)
Print "随机生成100个整数"
Dim i As Integer, j As Integer, md As Integer
Dim a(100) As Integer
q = 0
For i = 1 To 100
a(i) = Rnd() * 10000
Print a(i);
q = q + 1
If q = 10 Then
Print
q = 0
End If
Next i
'按从小到大排序
Print
Print "按从小到大排序"
For i = 1 To 100
For j = i To 100
If a(i) > a(j) Then
md = a(i)
a(i) = a(j)
a(j) = md
End If
Next j
Next i
q = 0
For i = 1 To 100
Print a(i);
q = q + 1
If q = 10 Then
Print
q = 0
End If
Next i
'按从大到小排序
Print
Print "按从大到小排序"
q = 0
For i = 100 To 1 Step -1
Print a(i);
q = q + 1
If q = 10 Then
Print
q = 0
End If
Next i
End Sub
2题
在Form里添加1个Timer控件和1个Label控件
Private Sub Form_Click()
'设置时间刷新间隔为2秒
Timer1.Interval = 2000
Label1 = Now()
End Sub
Private Sub Timer1_Timer()
Label1 = Now()
End Sub
Private Sub Form_Click()
'随机生成100个整数(本程序中整数数值设为10000以内)
Print "随机生成100个整数"
Dim i As Integer, j As Integer, md As Integer
Dim a(100) As Integer
q = 0
For i = 1 To 100
a(i) = Rnd() * 10000
Print a(i);
q = q + 1
If q = 10 Then
q = 0
End If
Next i
'按从小到大排序
Print "按从小到大排序"
For i = 1 To 100
For j = i To 100
If a(i) > a(j) Then
md = a(i)
a(i) = a(j)
a(j) = md
End If
Next j
Next i
q = 0
For i = 1 To 100
Print a(i);
q = q + 1
If q = 10 Then
q = 0
End If
Next i
'按从大到小排序
Print "按从大到小排序"
q = 0
For i = 100 To 1 Step -1
Print a(i);
q = q + 1
If q = 10 Then
q = 0
End If
Next i
End Sub
2题
在Form里添加1个Timer控件和1个Label控件
Private Sub Form_Click()
'设置时间刷新间隔为2秒
Timer1.Interval = 2000
Label1 = Now()
End Sub
Private Sub Timer1_Timer()
Label1 = Now()
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询