GUI Multiplication Table

GUI Multiplication Table



This code is shows how to create multiplication table in vb.net. Open a new windows project, place 2 textbox, list box and a button. In the button click write the following code.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <> "" And TextBox2.Text <> "" Then
' First Number is used to get the value from
' which number the multiplication start ie 1
' Second number used to get the end value
' ie 10,20
Dim firstNumber As Integer = Val(TextBox1.Text)
Dim secondNumber As Integer = Val(TextBox2.Text)
Dim multplier As Integer = 2 ' modify these value for 3,4
' for the corresponding table
Dim answer As Integer
Do While multplier < 3
For i = firstNumber To secondNumber
answer = i * multplier
' 1* 2= 2
'All the result will get appended to the listbox
lstTables.Items.Add(i & " * " & multplier & " = " & answer)
Next
multplier = multplier + 1
Loop
Else
Exit Sub
End If
End Sub


Comments

Author: Abhay Kumar Raut10 Nov 2009 Member Level: Gold   Points : 1

Hi Dharmaraj,

Can you please add some comment lines in the code?

Thanks,
Abhay



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: