vb通用过程简介

这篇博客介绍了几个VB中的通用过程,包括计算数组平均值、找出数组最大值以及数组排序。通过示例代码展示了如何使用这些过程,并在Command1_Click事件中演示了应用这些过程来处理和显示随机生成的数组元素。
摘要由CSDN通过智能技术生成

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, ByVal N 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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值