I need help writing a code that generates the first ten Fibonocci (not sure I spelled this word correctly), put them in an array and print it out the calculating has to start at the 3rd number. example 1 1 2 3 5
Printable View
I need help writing a code that generates the first ten Fibonocci (not sure I spelled this word correctly), put them in an array and print it out the calculating has to start at the 3rd number. example 1 1 2 3 5
Place a command button on your form and put the following code behind it:
Code:Private Sub Command1_Click()
Dim arrNums(1 To 10) As Integer
Dim intX As Integer
arrNums(1) = 1
arrNums(2) = 1
arrNums(3) = 2
For intX = 4 To 10
arrNums(intX) = arrNums(intX - 1) + arrNums(intX - 2)
Next
' print the numbers directly onto the form:
For intX = 1 To 10
Print arrNums(intX)
Next
End Sub