如何用vb的for循环语句制作1+1⼀2+1⼀3+1⼀4+1⼀5程序

2024-12-05 06:12:39
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim i As Integer
Dim s As Double
s = 0
N = 5
For i = 1 To N
s = s + 1 / i
Next i
Print s
End Sub

我写在按钮被按下的响应函数中了。N定义为5,运行结果是2.283333333333