VB返回值
这儿玩意儿怎么改啊,求求求求求求~~~~OptionExplicitPrivateSubCommand1_Click()DimsAsInteger,tAsSingle,i...
这儿玩意儿怎么改啊,求求求求求求~~~~
Option Explicit
Private Sub Command1_Click()
Dim s As Integer, t As Single, i As Integer
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If t < 0.0001 Then Exit Do
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f(n) = f(n - 1) + f(n - 2)
End If
End Function 展开
Option Explicit
Private Sub Command1_Click()
Dim s As Integer, t As Single, i As Integer
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If t < 0.0001 Then Exit Do
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f(n) = f(n - 1) + f(n - 2)
End If
End Function 展开
展开全部
共需要改三处:
Option Explicit
Private Sub Command1_Click()
Dim s As Single, t As Single, i As Integer '这里改
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If Abs(t) < 0.0001 Then Exit Do '这里改
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f = f(n - 1) + f(n - 2) '这里改
End If
End Function
Option Explicit
Private Sub Command1_Click()
Dim s As Single, t As Single, i As Integer '这里改
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If Abs(t) < 0.0001 Then Exit Do '这里改
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f = f(n - 1) + f(n - 2) '这里改
End If
End Function
展开全部
如果只是debug的话,把f(n) = f(n - 1) + f(n - 2) 改成f = f(n - 1) + f(n - 2) 就OK了
Private Sub Command1_Click()
Dim s As Integer, t As Single, i As Integer
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If t < 0.0001 Then Exit Do
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f = f(n - 1) + f(n - 2)
End If
End Function
Private Sub Command1_Click()
Dim s As Integer, t As Single, i As Integer
s = 0: i = 2
Do
t = (-1) ^ i / (f(i - 1) * f(i))
If t < 0.0001 Then Exit Do
s = s + t
i = i + 1
Loop
Print s
End Sub
Private Function f(ByVal n As Integer) As Integer
If n = 1 Or n = 2 Then
f = 1
Else
f = f(n - 1) + f(n - 2)
End If
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要改成什么样子哦,连需求都没有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询