Fibonacci Sequence in VB.net using loop
Just add
Label1.Text = Label1.Text + a.ToString & ControlChars.NewLine
Label1.Text = Label1.Text + b.ToString & ControlChars.NewLine
before the Do ... while
.
For applications linked to Fibonacci numbers see : Fibonacci: Applications
Instead of calculating the next in sequence number and then adding the results to the output, do it in reverse order:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer = 0
Dim b As Integer = 1
Dim fib As Integer
Do
Label1.Text += a.ToString & ControlChars.NewLine
fib = a + b
a = b
b = fib
Loop While a <= 55
End Sub