一条大一VB编程 求学霸
1个回答
展开全部
界面上放两个标签(label),一个按钮。代码如下
Private Sub Command1_Click()
Do
n = Int(InputBox("请输入计算项数", , 5))
If n > 0 Then Exit Do
Loop
a = 2
b = 1
s = 0
n1 = 1
Do Until n < n1
s = s + a / b
c = a + b
b = a
a = c
n1 = n1 + 1
Loop
Label2 = "前" & n & "项的和为:" & s
End Sub
Private Sub Form_Load()
Label1 = "s = 2/1 + 3/2 + 5/3 + 8/5 + 13/8 + ……"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询