1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
' Project name: Gwen Project
' Project purpose: The project allows the user to enter any number
' of sales amounts. It totals the sales amounts
' and then calculates a 10% bonus.
' use input box display total sales and a 10 % bonus
' Created/revised by: Andrew Damin (Comrade-Sergei) on 12/5/2007
Option Explicit On
Option Strict On
Imports System.Globalization
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
Const prompt As String = "Enter a Sales amount. Click Cancel to end"
Const title As String = "Sales Entry"
Dim inputSales As String
Dim sales As Decimal
Dim salesCounter As Integer
Dim salesAccumulator As Decimal
Dim bonus As Decimal
Dim isConverted As Boolean
inputSales = InputBox(prompt, title, "")
Do While inputSales <> String.Empty
isConverted = Decimal.TryParse(inputSales, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, sales)
If isConverted = True Then
salesCounter = salesCounter + 1
salesAccumulator = salesAccumulator + sales
Else
MessageBox.Show("Please re-enter the sales amount.", "Gwen", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
End If
inputSales = InputBox(prompt, title, "")
Loop
bonus = salesAccumulator * 0.1D
bonusLabel.Text = bonus.ToString("C2")
totalSalesLabel.Text = salesAccumulator.ToString("C2")
End Sub
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
|