vb编写s=(1+2+3+4+5+6+7+8)/(1+2+3+4+5)+(1+2+3+4+5+6)的代码

来源:百度知道 编辑:UC知道 时间:2024/09/23 10:45:34
用VB函数子过程编写 谁帮帮我啊

Private Function toSum(n%) As Long
Dim i, sn As Long
If n < 1 Then Exit Function
sn = 0
For i = 1 To n
sn = sn + i
Next
toSum = sn
End Function

Private Sub Command1_Click()
Print toSum(8) / toSum(5) + toSum(6)
Print toSum(8) / (toSum(5) + toSum(6)) '如果/后的都是分母
End Sub

function he(n) as double
for i=0 to n
he=he+i
next
end function

主程序:
Private Sub Command1_Click()
s=he(8)/he(5)+he(8)
print s
end sub