vb通用过程简介

前端之家收集整理的这篇文章主要介绍了vb通用过程简介前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Private Sub Ave(Arry() As Integer,ByVal N As Integer,Average As Integer)
Dim I As Integer,Sum As Integer
Sum = 0
For I = 1 To N - 1
Sum = Sum + Arry(I)
Next I
Average = Sum / N
End Sub

Private Sub Max(Arry() As Integer,M As Integer)
Dim I As Integer
M = Arry(0)
For I = 1 To N - 1
If Arry(I) > M Then
M = Arry(I)
End If
Next I
End Sub
Private Sub Sort(Arry() As Integer,ByVal N As Integer)
Dim I As Integer,J As Integer,K As Integer,Temp As Integer
For I = 0 To N - 2
K = I
For J = I + 1 To N - 1
If Arry(K) > Arry(J) Then
K = J
End If
Next J
If K > I Then
Temp = Arry(K)
Arry(K) = Arry(I)
Arry(I) = Temp
End If
Next I
End Sub

Private Sub Command1_Click() Dim Arra(10) As Integer,I As Integer,Average As Integer,Maxm As Integer For I = 0 To 9 Arra(I) = Rnd * 100 Print Arra(I); " "; Next I Print Call Sort(Arra,10) For I = 0 To 9 Print Arra(I); " "; Next I Print Call Max(Arra,10,Maxm) Call Ave(Arra,Average) Print "Max="; Maxm,"Ave="; Average Print End Sub

猜你在找的VB相关文章