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.
we will write the code under the click event of command button.
SOURCE CODEWe 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.
we will write the code under the click event of command button.
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.
Thanks this post helped me in compleating my assignment. Nice work.
ReplyDelete