求VB编程

利用子程序,编制程序计算∑10/(∑4+∑6)。(∑i=1+2+…+i)
2024-11-23 15:46:10
推荐回答(2个)
回答1:

Sub iMain()
Dim tmp
tmp = iSum(10) / (iSum(4) + iSum(6))
Print tmp
End Sub

Function iSum(n)
Dim i, tmp
For i = 1 To n
tmp = tmp + i
Next
iSum = tmp
End Function

回答2:

private function Sigma(n as integer) as integer
dim i as integer
Sigma=0
for i=1 to n
Sigma=Sigma+i
next
end function

private sub command1_click()
print Sigma(10) / (Sigma(4) + Sigma(6))
end sub