A time table program in VB.NET

Introduction

Here we will see a time table program in VB.NET. When the go button is clicked, the program will put the numbers in the Textbox. We'll then put a value into a variable called multiplier. If you're doing the time tables the format is:

X multiplied by Y = Z
(2 multiplied by 3 = 6)

We'll use a Do while Loop to work out the multiplier (that's the Y part). a For Loop will work out the rest. We'll then display the results in something a Listbox.

There a list box in that u have a list items that the user can select. here we are just using it display the result of program.

We will add item to the list box with our code rather than the design time like we did for the list box. The form will look like below


image-1.gif

So here is the code for the entire program.double click on Go to button and  write the following code.

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

        Dim number1 As Integer
        Dim
number2 As Integer
        Dim
multiplier As Integer
        Dim answer As Integer
        Dim i As Integer
        number1 = Val(TextBox1.Text)
        number2 = Val(TextBox2.Text)
        multiplier = 2
        Do While multiplier < 3
            For i = number1 To number2
                answer = i * multiplier
                ListBox1.Items.Add(i & " Times " & multiplier & " = " & answer)
            Next i
            multiplier = multiplier + 1
        Loop
    End Sub
End Class