【VB】用函数过程求表达式1+1⼀2+1⼀3+1⼀4+…+1⼀n的和.

2024-12-21 04:09:18
推荐回答(2个)
回答1:

Function Sum1(ByVal n As Intger) As Double
Dim i As Integer
Sum1=0
for i =1 to n
Sum1=Sum1+ 1/i
next i
End Function

回答2:

private function MyFunc(byval n as intger) as double
dim i as integer

for i =1 to n

MyFunc=Myfunc+ 1/i

next i

end function