Write a Visual Basic 2010 program to print Multiplication table from 6
table to 10 table ( till 5 series)in the List Box Control using menu strip
control.(Note: Use Do While Loop and differentiate all tables with
different colors)
Form1.Designer.vb file:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
Me.MultiplicationTableToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.TableShortcutKeyAlt1ToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.TableShortcutKeyAlt1ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
Me.TableShortcutKeyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.TableShortcutKeyToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem()
Me.TableShortcutKeyToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem()
Me.AllTablesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.lstTable6 = New System.Windows.Forms.ListBox()
Me.lstTable7 = New System.Windows.Forms.ListBox()
Me.lstTable8 = New System.Windows.Forms.ListBox()
Me.lstTable9 = New System.Windows.Forms.ListBox()
Me.lstTable10 = New System.Windows.Forms.ListBox()
Me.MenuStrip1.SuspendLayout()
Me.SuspendLayout()
'
'MenuStrip1
'
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MultiplicationTableToolStripMenuItem})
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(654, 24)
Me.MenuStrip1.TabIndex = 0
Me.MenuStrip1.Text = "MenuStrip1"
'
'MultiplicationTableToolStripMenuItem
'
Me.MultiplicationTableToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TableShortcutKeyAlt1ToolStripMenuItem, Me.TableShortcutKeyAlt1ToolStripMenuItem1, Me.TableShortcutKeyToolStripMenuItem, Me.TableShortcutKeyToolStripMenuItem1, Me.TableShortcutKeyToolStripMenuItem2, Me.AllTablesToolStripMenuItem})
Me.MultiplicationTableToolStripMenuItem.Name = "MultiplicationTableToolStripMenuItem"
Me.MultiplicationTableToolStripMenuItem.Size = New System.Drawing.Size(124, 20)
Me.MultiplicationTableToolStripMenuItem.Text = "Multiplication Table"
'
'TableShortcutKeyAlt1ToolStripMenuItem
'
Me.TableShortcutKeyAlt1ToolStripMenuItem.Name = "TableShortcutKeyAlt1ToolStripMenuItem"
Me.TableShortcutKeyAlt1ToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.D6), System.Windows.Forms.Keys)
Me.TableShortcutKeyAlt1ToolStripMenuItem.Size = New System.Drawing.Size(234, 22)
Me.TableShortcutKeyAlt1ToolStripMenuItem.Text = "6 Table Shortcut key:"
'
'TableShortcutKeyAlt1ToolStripMenuItem1
'
Me.TableShortcutKeyAlt1ToolStripMenuItem1.Name = "TableShortcutKeyAlt1ToolStripMenuItem1"
Me.TableShortcutKeyAlt1ToolStripMenuItem1.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.D7), System.Windows.Forms.Keys)
Me.TableShortcutKeyAlt1ToolStripMenuItem1.Size = New System.Drawing.Size(234, 22)
Me.TableShortcutKeyAlt1ToolStripMenuItem1.Text = "7 Table Shortcut key:"
'
'TableShortcutKeyToolStripMenuItem
'
Me.TableShortcutKeyToolStripMenuItem.Name = "TableShortcutKeyToolStripMenuItem"
Me.TableShortcutKeyToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.D8), System.Windows.Forms.Keys)
Me.TableShortcutKeyToolStripMenuItem.Size = New System.Drawing.Size(234, 22)
Me.TableShortcutKeyToolStripMenuItem.Text = "8 Table Shortcut key:"
'
'TableShortcutKeyToolStripMenuItem1
'
Me.TableShortcutKeyToolStripMenuItem1.Name = "TableShortcutKeyToolStripMenuItem1"
Me.TableShortcutKeyToolStripMenuItem1.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.D9), System.Windows.Forms.Keys)
Me.TableShortcutKeyToolStripMenuItem1.Size = New System.Drawing.Size(234, 22)
Me.TableShortcutKeyToolStripMenuItem1.Text = "9 Table Shortcut key:"
'
'TableShortcutKeyToolStripMenuItem2
'
Me.TableShortcutKeyToolStripMenuItem2.Name = "TableShortcutKeyToolStripMenuItem2"
Me.TableShortcutKeyToolStripMenuItem2.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.D1), System.Windows.Forms.Keys)
Me.TableShortcutKeyToolStripMenuItem2.Size = New System.Drawing.Size(234, 22)
Me.TableShortcutKeyToolStripMenuItem2.Text = "10 Table Shortcut key:"
'
'AllTablesToolStripMenuItem
'
Me.AllTablesToolStripMenuItem.Name = "AllTablesToolStripMenuItem"
Me.AllTablesToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.A), System.Windows.Forms.Keys)
Me.AllTablesToolStripMenuItem.Size = New System.Drawing.Size(234, 22)
Me.AllTablesToolStripMenuItem.Text = "All Tables Shortcut key:"
'
'lstTable6
'
Me.lstTable6.BackColor = System.Drawing.Color.Blue
Me.lstTable6.ForeColor = System.Drawing.Color.White
Me.lstTable6.FormattingEnabled = True
Me.lstTable6.Location = New System.Drawing.Point(28, 48)
Me.lstTable6.Name = "lstTable6"
Me.lstTable6.Size = New System.Drawing.Size(112, 173)
Me.lstTable6.TabIndex = 1
'
'lstTable7
'
Me.lstTable7.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(128, Byte), Integer))
Me.lstTable7.ForeColor = System.Drawing.Color.White
Me.lstTable7.FormattingEnabled = True
Me.lstTable7.Location = New System.Drawing.Point(146, 48)
Me.lstTable7.Name = "lstTable7"
Me.lstTable7.Size = New System.Drawing.Size(112, 173)
Me.lstTable7.TabIndex = 1
'
'lstTable8
'
Me.lstTable8.BackColor = System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
Me.lstTable8.FormattingEnabled = True
Me.lstTable8.Location = New System.Drawing.Point(264, 48)
Me.lstTable8.Name = "lstTable8"
Me.lstTable8.Size = New System.Drawing.Size(112, 173)
Me.lstTable8.TabIndex = 1
'
'lstTable9
'
Me.lstTable9.BackColor = System.Drawing.Color.Lime
Me.lstTable9.FormattingEnabled = True
Me.lstTable9.Location = New System.Drawing.Point(382, 48)
Me.lstTable9.Name = "lstTable9"
Me.lstTable9.Size = New System.Drawing.Size(112, 173)
Me.lstTable9.TabIndex = 1
'
'lstTable10
'
Me.lstTable10.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer))
Me.lstTable10.FormattingEnabled = True
Me.lstTable10.Location = New System.Drawing.Point(500, 48)
Me.lstTable10.Name = "lstTable10"
Me.lstTable10.Size = New System.Drawing.Size(112, 173)
Me.lstTable10.TabIndex = 1
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(654, 248)
Me.Controls.Add(Me.lstTable10)
Me.Controls.Add(Me.lstTable9)
Me.Controls.Add(Me.lstTable8)
Me.Controls.Add(Me.lstTable7)
Me.Controls.Add(Me.lstTable6)
Me.Controls.Add(Me.MenuStrip1)
Me.MainMenuStrip = Me.MenuStrip1
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Multiplication table "
Me.MenuStrip1.ResumeLayout(False)
Me.MenuStrip1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
Friend WithEvents MultiplicationTableToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TableShortcutKeyAlt1ToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TableShortcutKeyAlt1ToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TableShortcutKeyToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TableShortcutKeyToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TableShortcutKeyToolStripMenuItem2 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents AllTablesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents lstTable6 As System.Windows.Forms.ListBox
Friend WithEvents lstTable7 As System.Windows.Forms.ListBox
Friend WithEvents lstTable8 As System.Windows.Forms.ListBox
Friend WithEvents lstTable9 As System.Windows.Forms.ListBox
Friend WithEvents lstTable10 As System.Windows.Forms.ListBox
End Class
Form1.vb file:
Public Class Form1
''' <summary>
''' Form1 Load
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
displayTable(6, lstTable6)
displayTable(7, lstTable7)
displayTable(8, lstTable8)
displayTable(9, lstTable9)
displayTable(10, lstTable10)
End Sub
''' <summary>
''' display table
''' </summary>
''' <param name="number"></param>
''' <param name="lstTable"></param>
''' <remarks></remarks>
Private Sub displayTable(ByVal number As Integer, ByVal lstTable As ListBox)
Dim counter As Integer = 1
lstTable.Items.Clear()
Do While (counter <= number)
Dim product As Integer = counter * number
lstTable.Items.Add(counter.ToString() + " x " + number.ToString() + " = " + product.ToString())
counter += 1
Loop
End Sub
Private Sub TableShortcutKeyAlt1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableShortcutKeyAlt1ToolStripMenuItem.Click
displayTable(6, lstTable6)
lstTable6.BackColor = lstTable6.BackColor
lstTable6.ForeColor = lstTable6.ForeColor
lstTable7.Visible = False
lstTable8.Visible = False
lstTable9.Visible = False
lstTable10.Visible = False
Size = New Size(176, 287)
End Sub
Private Sub TableShortcutKeyAlt1ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableShortcutKeyAlt1ToolStripMenuItem1.Click
displayTable(7, lstTable6)
lstTable6.BackColor = lstTable7.BackColor
lstTable6.ForeColor = lstTable7.ForeColor
lstTable7.Visible = False
lstTable8.Visible = False
lstTable9.Visible = False
lstTable10.Visible = False
Size = New Size(176, 287)
End Sub
Private Sub TableShortcutKeyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableShortcutKeyToolStripMenuItem.Click
displayTable(8, lstTable6)
lstTable6.BackColor = lstTable8.BackColor
lstTable6.ForeColor = lstTable8.ForeColor
lstTable7.Visible = False
lstTable8.Visible = False
lstTable9.Visible = False
lstTable10.Visible = False
Size = New Size(176, 287)
End Sub
Private Sub TableShortcutKeyToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableShortcutKeyToolStripMenuItem1.Click
displayTable(9, lstTable6)
lstTable6.BackColor = lstTable9.BackColor
lstTable6.ForeColor = lstTable9.ForeColor
lstTable7.Visible = False
lstTable8.Visible = False
lstTable9.Visible = False
lstTable10.Visible = False
Size = New Size(176, 287)
End Sub
Private Sub TableShortcutKeyToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableShortcutKeyToolStripMenuItem2.Click
displayTable(10, lstTable6)
lstTable6.BackColor = lstTable10.BackColor
lstTable6.ForeColor = lstTable10.ForeColor
lstTable7.Visible = False
lstTable8.Visible = False
lstTable9.Visible = False
lstTable10.Visible = False
Size = New Size(176, 287)
End Sub
Private Sub AllTablesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllTablesToolStripMenuItem.Click
Form1_Load(sender, e)
lstTable6.BackColor = Color.Blue
lstTable6.ForeColor = Color.White
lstTable7.Visible = True
lstTable8.Visible = True
lstTable9.Visible = True
lstTable10.Visible = True
Size = New Size(670, 287)
End Sub
End Class
Examples:
Comments
Leave a comment