Visual Basic Assignment - Practical Exercises with Code and Output

Verified

Added on  2022/08/14

|28
|1340
|14
Practical Assignment
AI Summary
This document presents a comprehensive Visual Basic assignment solution, covering multiple programming exercises. The assignment includes code implementations for calculating average sales, utilizing input boxes, timer controls, and loop structures. It also features exercises involving form design, user input, and output display. The solution is thoroughly tested, with screenshots demonstrating the application's functionality and output for different scenarios. The document includes code snippets and visual representations of the application's behavior, making it a valuable resource for students learning Visual Basic programming and application development. The exercises include code to move an image up and down on the form. The document is available on Desklib, a platform offering AI-based study tools for students.
Document Page
Running head: VISUAL BASIC ASSIGNMENT
Visual Basic Assignment
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 ASSIGNMENT
Exercise 3
Code Part:
Public Class frmMain
Dim count As Integer = 0
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles
btnCalc.Click
' calculates and displays the average sales amount
Dim values As Integer = 0
Dim netsales As Integer = 0
Dim sales As Integer
Dim i As Integer
Dim numberOfSales As String = InputBox("Enter the number of Sales",
"Sales Express", 0)
'numberOfSales
If numberOfSales = "" Then
Exit Sub
ElseIf numberOfSales = 0 Then
MessageBox.Show("No Sales Amounts were entered.")
Else
values = Convert.ToInt32(numberOfSales)
For i = 1 To values
sales = InputBox("Enter Sales amount for Sales ", "Sales
Express", 0)
netsales += sales
Next
values = netsales / values
End If
lblAvg.Text = values.ToString("C2")
lblAvg.BorderStyle = BorderStyle.None
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles
Timer1.Tick
Document Page
2VISUAL BASIC ASSIGNMENT
If count <> 5 Then
Timer2.Enabled = True
lblAvg.ForeColor = Color.Red
Timer1.Enabled = False
count += 1
Else
count = 0
Timer1.Enabled = False
lblAvg.BorderStyle = BorderStyle.FixedSingle
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles
Timer2.Tick
Timer1.Enabled = True
lblAvg.ForeColor = Color.Black
Timer2.Enabled = False
End Sub
End Class
Testing the data:
Fig: Initial run of the application
Document Page
3VISUAL BASIC ASSIGNMENT
Fig: Taking Data using Input Box
Fig: Entering zero as an input
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 ASSIGNMENT
Fig: Result on entering zero as an input
Fig: Highlighting the result on entering values as an input
Fig: After blinking the text result five times
Document Page
5VISUAL BASIC ASSIGNMENT
Exercise 4 (Part1)
Code Part:
Public Class Form1
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles
btnClear.Click
txtInput.Text = ""
txtOutput.Text = ""
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles
btnStart.Click
Dim intNumberOfCustomers As Integer
Dim intCustomer As Integer
intNumberOfCustomers = txtInput.Text
intCustomer = 1
Do Until intNumberOfCustomers = 0
txtOutput.Text = "Accepting the Book from Customer " +
intCustomer.ToString() + "."
Me.Refresh()
Threading.Thread.Sleep(2000)
txtOutput.Text = "Placing the book on the table."
Me.Refresh()
Threading.Thread.Sleep(2000)
txtOutput.Text = "Opened the front cover of the book."
Me.Refresh()
Threading.Thread.Sleep(2000)
txtOutput.Text = "Signing the first page of the book."
Me.Refresh()
Threading.Thread.Sleep(2000)
txtOutput.Text = "Closing the Book."
Me.Refresh()
Threading.Thread.Sleep(2000)
txtOutput.Text = "Returning the book to the Customer."
Me.Refresh()
Document Page
6VISUAL BASIC ASSIGNMENT
Threading.Thread.Sleep(2000)
txtOutput.Text = "Thanking Customer " + intCustomer.ToString() +
"."
Me.Refresh()
Threading.Thread.Sleep(2000)
intCustomer += 1
intNumberOfCustomers -= 1
Loop
txtOutput.Text = "All Books Signed!!..."
End Sub
End Class
Testing the application:
Fig: Initial run of the application
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
7VISUAL BASIC ASSIGNMENT
Fig: Running the application with 2 as an input (Part 1)
Fig: Running the application with 2 as an input (Part 2)
Document Page
8VISUAL BASIC ASSIGNMENT
Fig: Running the application with 2 as an input (Part 3)
Fig: Running the application with 2 as an input (Part 4)
Document Page
9VISUAL BASIC ASSIGNMENT
Fig: Running the application with 2 as an input (Part 5)
Fig: Running the application with 2 as an input (Part 6)
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
10VISUAL BASIC ASSIGNMENT
Fig: Running the application with 2 as an input (Part 7)
Fig: Running the application with 2 as an input (Part 8)
Document Page
11VISUAL BASIC ASSIGNMENT
Fig: Running the application with 2 as an input (Part 9)
Fig: Running the application with 2 as an input (Part 10)
chevron_up_icon
1 out of 28
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]