Linggo, Marso 16, 2014

Fibonacci Series Tutorial In VBA

go to your developer tab and open visual basic.
insert userform, and then add a label, textbox,listbox ,and commanbutton into your userform.
just like this picture below:













you can change the name of your label and button by simply go to caption and edit.

double click your command button and type this following code:

Private Sub CommandButton1_Click()
Dim x, y, n, i, sum  As Integer
n = TextBox1.Text

xValue = 0
yValue = 1

For i = 1 To n
xValue = yValue
yValue = sum
sum = xValue + yValue
ListBox1.AddItem sum

Next i


End Sub

Run your Program, lets assume that the user will input a value of 10.

 
click the button and the fibo series of 10 will save on the listbox just like example below:

Hope this will help... :-)