VB:有一个数列,前两个数是1,1,……要求输出此数列的前30个数.Private Sub Command1_Click()Dim a(30)If Option1.Value = True Thena(1) = 1a(2) = 1For i = 3 To 30a(i) = Val(a(i - 1)) + Val(a(i - 2))NextText1.Text = a(30)End Ifend sub这
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 15:42:53
![VB:有一个数列,前两个数是1,1,……要求输出此数列的前30个数.Private Sub Command1_Click()Dim a(30)If Option1.Value = True Thena(1) = 1a(2) = 1For i = 3 To 30a(i) = Val(a(i - 1)) + Val(a(i - 2))NextText1.Text = a(30)End Ifend sub这](/uploads/image/z/3144779-35-9.jpg?t=VB%3A%E6%9C%89%E4%B8%80%E4%B8%AA%E6%95%B0%E5%88%97%2C%E5%89%8D%E4%B8%A4%E4%B8%AA%E6%95%B0%E6%98%AF1%2C1%2C%E2%80%A6%E2%80%A6%E8%A6%81%E6%B1%82%E8%BE%93%E5%87%BA%E6%AD%A4%E6%95%B0%E5%88%97%E7%9A%84%E5%89%8D30%E4%B8%AA%E6%95%B0.Private+Sub+Command1_Click%28%29Dim+a%2830%29If+Option1.Value+%3D+True+Thena%281%29+%3D+1a%282%29+%3D+1For+i+%3D+3+To+30a%28i%29+%3D+Val%28a%28i+-+1%29%29+%2B+Val%28a%28i+-+2%29%29NextText1.Text+%3D+a%2830%29End+Ifend+sub%E8%BF%99)
VB:有一个数列,前两个数是1,1,……要求输出此数列的前30个数.Private Sub Command1_Click()Dim a(30)If Option1.Value = True Thena(1) = 1a(2) = 1For i = 3 To 30a(i) = Val(a(i - 1)) + Val(a(i - 2))NextText1.Text = a(30)End Ifend sub这
VB:有一个数列,前两个数是1,1,……要求输出此数列的前30个数.
Private Sub Command1_Click()
Dim a(30)
If Option1.Value = True Then
a(1) = 1
a(2) = 1
For i = 3 To 30
a(i) = Val(a(i - 1)) + Val(a(i - 2))
Next
Text1.Text = a(30)
End If
end sub
这是我写的,但运行之后不对,请大侠指出错误~
VB:有一个数列,前两个数是1,1,……要求输出此数列的前30个数.Private Sub Command1_Click()Dim a(30)If Option1.Value = True Thena(1) = 1a(2) = 1For i = 3 To 30a(i) = Val(a(i - 1)) + Val(a(i - 2))NextText1.Text = a(30)End Ifend sub这
Private Sub Command1_Click()
Dim a(30) as Integer
If Option1.Value = True Then
a(1) = 1
a(2) = 1
For i = 3 To 30
a(i) =a(i - 1) + a(i - 2)
Next
Text1.Text =str(a(30))
End If
end sub