Multiplication Table in VB.NET

Submitted by: 
Visitors have accessed this post 14171 times.

Hi! this is me again! For now we will have to create a Multiplication Table using VB.NET.

So, now let's start this tutorial!

1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.

2. Next, add Three TextBoxes namely TextBox1 for entering the first number, TextBox2 for entering the number limit, and TextBox3 for the result of the Multiplication Table. You must design your layout like this:

Design

3. Next, put this code in Button1_Click so that it will display the Multiplication table.

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim n1, n2, i As Integer
  3. n1 = Val(TextBox1.Text)
  4. n2 = Val(TextBox2.Text)
  5.  
  6. For i = 1 To n2
  7. Dim a As Integer
  8. a = n1 * i
  9. TextBox3.Text = TextBox3.Text & n1 & " * " & i & " = " & a
  10. TextBox3.Text = TextBox3.Text & vbCrLf
  11. Next
  12. End Sub

Explanation:
We initialized n1, n2 as Integer because we passed the value of our input in TextBox1 to n1 and TextBox2 to n2.

  1. For i = 1 To n2
  2. Dim a As Integer
  3. a = n1 * i
  4. TextBox3.Text = TextBox3.Text & n1 & " * " & i & " = " & a
  5. TextBox3.Text = TextBox3.Text & vbCrLf
  6. Next

For i = 1 To n2 - our variable i will start at 1 up to the n2 as we input it in TextBox2. Next, we initialized a as Integer to have the result of multiplication done in n1 up to the value of i which limits at n2. Then, TextBox3 will now have the value of n1*i = a. We use vbCrLf to create a newline.

Now, input 8 in TextBox1 and 10 in TexBox2 then click the Button. It will have a multiplication table like the image below.

output

Download the source code below and try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
STI College - Surigao City
Mobile: 09488225971
E-mail:[email protected]

Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.