Answer to Question #189183 in Visual Basic for Carl

Question #189183

The sales manager at ITI Hub has asked you to design and implement a Windows application that will display the total sales made in there three regions in South Africa: Kwazulu-Natal, Gauteng and Western cape. The application should display the total sales of the company as well as the percentage that each region contributed to the total sales. It should show sales for 6 months


1
Expert's answer
2021-05-06T05:13:17-0400
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ITIHubSalesAmountForm
    Inherits System.Windows.Forms.Form


    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub


    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer


    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.lstKwazuluNatal = New System.Windows.Forms.ListBox()
        Me.lstGauteng = New System.Windows.Forms.ListBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.lblTotal = New System.Windows.Forms.Label()
        Me.lstWestern = New System.Windows.Forms.ListBox()
        Me.SuspendLayout()
        '
        'lstKwazuluNatal
        '
        Me.lstKwazuluNatal.FormattingEnabled = True
        Me.lstKwazuluNatal.ItemHeight = 20
        Me.lstKwazuluNatal.Location = New System.Drawing.Point(33, 68)
        Me.lstKwazuluNatal.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.lstKwazuluNatal.Name = "lstKwazuluNatal"
        Me.lstKwazuluNatal.Size = New System.Drawing.Size(178, 304)
        Me.lstKwazuluNatal.TabIndex = 0
        '
        'lstGauteng
        '
        Me.lstGauteng.FormattingEnabled = True
        Me.lstGauteng.ItemHeight = 20
        Me.lstGauteng.Location = New System.Drawing.Point(280, 68)
        Me.lstGauteng.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.lstGauteng.Name = "lstGauteng"
        Me.lstGauteng.Size = New System.Drawing.Size(178, 304)
        Me.lstGauteng.TabIndex = 1
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(524, 29)
        Me.Label5.Margin = New System.Windows.Forms.Padding(9, 0, 9, 0)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(69, 20)
        Me.Label5.TabIndex = 4
        Me.Label5.Text = "Western"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(276, 29)
        Me.Label4.Margin = New System.Windows.Forms.Padding(9, 0, 9, 0)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(72, 20)
        Me.Label4.TabIndex = 5
        Me.Label4.Text = "Gauteng"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(28, 29)
        Me.Label2.Margin = New System.Windows.Forms.Padding(9, 0, 9, 0)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(110, 20)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "Kwazulu-Natal"
        '
        'lblTotal
        '
        Me.lblTotal.AutoSize = True
        Me.lblTotal.Location = New System.Drawing.Point(28, 414)
        Me.lblTotal.Margin = New System.Windows.Forms.Padding(9, 0, 9, 0)
        Me.lblTotal.Name = "lblTotal"
        Me.lblTotal.Size = New System.Drawing.Size(310, 20)
        Me.lblTotal.TabIndex = 3
        Me.lblTotal.Text = "The total sales made in there three regions"
        '
        'lstWestern
        '
        Me.lstWestern.FormattingEnabled = True
        Me.lstWestern.ItemHeight = 20
        Me.lstWestern.Location = New System.Drawing.Point(528, 68)
        Me.lstWestern.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.lstWestern.Name = "lstWestern"
        Me.lstWestern.Size = New System.Drawing.Size(178, 304)
        Me.lstWestern.TabIndex = 1
        '
        'ITIHubSalesAmountForm
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(778, 465)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.lblTotal)
        Me.Controls.Add(Me.lstWestern)
        Me.Controls.Add(Me.lstGauteng)
        Me.Controls.Add(Me.lstKwazuluNatal)
        Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "ITIHubSalesAmountForm"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "ITI Hub Sales Amount"
        Me.ResumeLayout(False)
        Me.PerformLayout()


    End Sub
    Friend WithEvents lstKwazuluNatal As System.Windows.Forms.ListBox
    Friend WithEvents lstGauteng As System.Windows.Forms.ListBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents lblTotal As System.Windows.Forms.Label
    Friend WithEvents lstWestern As System.Windows.Forms.ListBox


End Class





Public Class ITIHubSalesAmountForm


    Private Sub ITIHubSalesAmountForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sales_Amount(,) As Integer = {{120000, 190000, 175000, 188000, 125000, 163000},
                                    {90000, 85000, 80000, 83000, 87000, 80000},
                                    {65000, 64000, 71000, 67000, 65000, 64000}}


        Dim total_Sales As Integer = 0
        Dim total_SalesKwazuluNatal As Integer = 0
        Dim total_Sales_Western As Integer = 0


        Dim total_Sales_Gauteng As Integer = 0
        Dim gauteng_Percentages As Integer = 0
        Dim kwazulu_Natal_Percentages As Integer = 0
        Dim western_Percentages As Integer = 0




        For j As Integer = 0 To 5
            total_SalesKwazuluNatal += sales_Amount(0, j)
            total_Sales_Gauteng += sales_Amount(1, j)
            total_Sales_Western += sales_Amount(2, j)




            lstKwazuluNatal.Items.Add(sales_Amount(0, j).ToString())
            lstGauteng.Items.Add(sales_Amount(1, j).ToString())
            lstWestern.Items.Add(sales_Amount(2, j).ToString())
        Next


        total_Sales = total_SalesKwazuluNatal + total_Sales_Gauteng + total_Sales_Western
        kwazulu_Natal_Percentages = (total_SalesKwazuluNatal / total_Sales) * 100
        gauteng_Percentages = (total_Sales_Gauteng / total_Sales) * 100
        western_Percentages = (total_Sales_Western / total_Sales) * 100


        lstKwazuluNatal.Items.Add("Total sales = " + Math.Ceiling(total_SalesKwazuluNatal).ToString())
        lstGauteng.Items.Add("Total sales = " + Math.Ceiling(total_Sales_Gauteng).ToString())
        lstWestern.Items.Add("Total sales = " + Math.Ceiling(total_Sales_Western).ToString())


        lstKwazuluNatal.Items.Add("Percentage = " + Math.Ceiling(kwazulu_Natal_Percentages).ToString() + "%")
        lstGauteng.Items.Add("Percentage = " + Math.Ceiling(gauteng_Percentages).ToString() + "%")
        lstWestern.Items.Add("Percentage = " + Math.Ceiling(western_Percentages).ToString() + "%")
        lblTotal.Text = "The total sales made in three regions: " + total_Sales.ToString()


    End Sub
End Class




Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS