VB.NET Table Creation Project Assignment - University Name

Verified

Added on  2022/08/09

|5
|370
|24
Project
AI Summary
This assignment is a VB.NET project focused on creating multiplication tables. The solution demonstrates the use of both Do...Loop and For...Next statements to generate tables based on user input. The project includes code for the main form, event handlers for button clicks (to trigger table generation), text box input (for specifying the number), and input validation. The code also includes event handlers for text box selection and key press to ensure only numerical input is accepted. The application is tested with different values and both loops to show the functionality of the code. This project allows students to understand and implement fundamental programming concepts in VB.NET to create a practical application.
Document Page
Running head: VISUAL BASIC TABLE CREATION
VISUAL BASIC TABLE CREATION
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1VISUAL BASIC TABLE CREATION
Solution 8
Code Part:
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Dim int As Integer
Private Sub btnDoLoop_Click(sender As Object, e As EventArgs) Handles
btnDoLoop.Click
' Displays a multiplication table.
Dim num As Integer = Convert.ToInt32(txtNumber.Text)
Dim mul As Integer
int = 1
Do While int <= 9
mul = num * int
lblTable.Text = lblTable.Text & num.ToString & " * " &
int.ToString & " = " & mul.ToString & ControlChars.NewLine
int += 1
Loop
End Sub
Private Sub btnForNext_Click(sender As Object, e As EventArgs) Handles
btnForNext.Click
' Displays a multiplication table.
Dim num As Integer = Convert.ToInt32(txtNumber.Text)
Dim mul As Integer
For int = 1 To 9
mul = num * int
lblTable.Text = lblTable.Text & num.ToString & " * " &
int.ToString & " = " & mul.ToString & ControlChars.NewLine
Next int
End Sub
Private Sub txtNumber_Enter(sender As Object, e As EventArgs) Handles
txtNumber.Enter
txtNumber.SelectAll()
End Sub
Private Sub txtNumber_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtNumber.KeyPress
' Allow only numbers and the Backspace key.
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <>
ControlChars.Back Then
e.Handled = True
End If
End Sub
Document Page
2VISUAL BASIC TABLE CREATION
Private Sub txtNumber_TextChanged(sender As Object, e As EventArgs)
Handles txtNumber.TextChanged
lblTable.Text = String.Empty
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
End Class
Document Page
3VISUAL BASIC TABLE CREATION
Testing the application with data:
Fig: Testing the application with same value as the problem statement (For…Next)
Fig: Testing the application with same value as the problem statement (Do…Loop)
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4VISUAL BASIC TABLE CREATION
Fig: Testing the application with different value than that of the problem statement (For…
Next)
Fig: Testing the application with different value than that of the problem statement (Do…
Loop)
chevron_up_icon
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]