Download as pdf or txt
Download as pdf or txt
You are on page 1of 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