Visual Basic | Fibonacci Sequence - wordsclank.in

Sunday 9 April 2017

Visual Basic | Fibonacci Sequence

Guys..
We are going to generate Fibonacci sequence in Vb.Fibonacci series is the series in the the first term starts from 0 and next term will be addition of the previous two terms.

we will design the form in which we will take one text box for taking the input up-to which the series will be generated and one command button.

Fibonacci series, Visual Basic
we will write the code under the click event of command button.







SOURCE CODE


Private Sub Command1_Click( )


Dim  n, a, b, c as Integer

n = val(Text1.Text)

  a =0

  b =1

  Print a

  Print b

 For i = 1 To n - 2

    c = a + b

    a = b

    b = c

    Print c

 Next i

End Sub




NOTE:
 1.The program uses if next loop structure.
 2.Dim is used to declared a variable.
 3.Val function is used to change a string to numeric.

Thanks for reading the post.Hope this will help you.If you have any doubts comment on the comment section, we will be happy to help you.

1 comment:

  1. Thanks this post helped me in compleating my assignment. Nice work.

    ReplyDelete