资 源 简 介
VB6.0 代码演示如何计算加权平均值,计算加权平均值可编写以下代码实现:
Private Sub Command1_Click()
Text7.Text = jiaquan(Text1, Text2, Text3, Text4, Text5, Text6)
End Sub
Private Function jiaquan(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer)
Dim sum As Integer
sum = (a * b + c * d + e * f) / (b + d + f)
sum = Round(sum, 2)
jiaquan = sum
End Function