0% found this document useful (0 votes)
33 views

Lesson Example Variables and Data Types

The document describes a Visual Basic lesson example for calculating sales data. It includes: - An app that takes a list of weekly sales from the user and calculates the total sales, 2% of total sales, 5% of total sales, lowest weekly sale, and highest weekly sale. - The user interface allows the user to enter weekly sales data. - The main code has buttons to calculate 2% tax on total sales, 5% tax on total sales, and exit. It also calculates the running total, minimum, and maximum sales on each input.

Uploaded by

David Tawiah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Lesson Example Variables and Data Types

The document describes a Visual Basic lesson example for calculating sales data. It includes: - An app that takes a list of weekly sales from the user and calculates the total sales, 2% of total sales, 5% of total sales, lowest weekly sale, and highest weekly sale. - The user interface allows the user to enter weekly sales data. - The main code has buttons to calculate 2% tax on total sales, 5% tax on total sales, and exit. It also calculates the running total, minimum, and maximum sales on each input.

Uploaded by

David Tawiah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CICS 313:

Visual Basic Programming

Variables and Data Types


- Lesson Example -

Ghana Technology University College


Lecturer – Dr. Forgor Lempogo
2021
Main Lesson Example
An App that will take a list of weekly sales from

the user, then calculate and display the following:


Total Sales

2% of the Total Sales

5% of the Total Sales

Lowest Weekly Sale

Highest Weekly Sale

2 CICS 313:Visual Basic Programming - GTUC 2021 Delivery


User Interface
An App that will take a list of weekly sales from

the user, then calculate and display the following:


Total Sales

2% of the Total Sales

5% of the Total Sales

Lowest Weekly Sale

Highest Weekly Sale

3 CICS 313:Visual Basic Programming - GTUC 2021 Delivery


Main Code (1/3)
Public Class VariablesDT
Private sale As Double
Private Sub btnTax2_Click(sender As Object, e As EventArgs) Handles btnTax2.Click
'Dim sale As Double
Dim tax2 As Double
Dim totalsalestring As String
totalsalestring = txtTotalSales.Text.Remove(0, 4)
Double.TryParse(totalsalestring, sale)
tax2 = 0.02 * sale
txtTax.Text = tax2.ToString("c2")
For x As Integer = 0 To 10
Dim tp As Double
Next
End Sub

4 CICS 313:Visual Basic Programming - GTUC 2021 Delivery


Main Code (2/3)
Private Sub btnTax5_Click(sender As Object, e As EventArgs) Handles
btnTax5.Click
Dim tax5 As Double
Double.TryParse(txtTotalSales.Text.Remove(0, 4), sale)
tax5 = 0.05 * sale
txtTax.Text = tax5.ToString("C2")
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles


btnExit.Click
Me.Close()
End Sub
End Class

5 CICS 313:Visual Basic Programming - GTUC 2021 Delivery


Private Sub btnSale_Click(sender As Object, e As EventArgs) Handles btnSale.Click
Main Lesson Problem
Static TotalSales As Double
Double.TryParse(txtSale.Text, sale)
TotalSales += sale
txtTotalSales.Text = TotalSales.ToString("C2")
Static min, max, saleCount As Integer
saleCount += 1
If saleCount <= 1 Then
min = sale
max = sale
Else
If sale > max Then
max = sale
ElseIf sale < min Then
min = sale
End If
End If
txtMax.Text = max.ToString("C2")
txtMin.Text = min.ToString("C2")
End Sub
6
End Class

You might also like