We can write a VB2015 to generate generate a geometric progression based on the following formula:

the nth term of a GP is ar^n-1, where a is the first term, r the common ratio and n is the number of terms.

To create the code, we insert the following controls:

List Box- to display the output

textbox 1 – to let user input the first number

textbox 2 – to let user input the common ratio

textbox3 – to let user input the number of terms.

We use the syntax

ListBox1.Items.Add(x)

to add the numbers generated to the list box

And we use the do loop to generate the numbers.

**The Code**

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

ListBox1.Items.Clear()

Dim n, num As Integer

Dim x, r As Single

x = Txt_FirstNum.Text

r = Txt_CR.Text

num = Txt_terms.Text

ListBox1.Items.Add(“n” & vbTab & “x”)

ListBox1.Items.Add(“___________”)

n = 1

ListBox1.Items.Add(n & vbTab & x)

Do

x = x * r

n = n + 1

ListBox1.Items.Add(n & vbTab & Format(x, “0.00”))

Loop Until n = num + 1

End Sub

End Class

The Design Interface

The Output