Answer to Question #189179 in Visual Basic for Mvelo

Question #189179

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. Display the sales amounts with a Rand sign and no decimal places. Display the percentages with a percent symbol with no decimal places. The sales amounts for six months are shown in Figure 3. Create a windows application form for this project using the name ITI Hub regional sales. Store the sales amount in a two-dimensional array. Create a suitable interface with an image for the project and run the application


1
Expert's answer
2021-05-05T08:49:54-0400
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class mainForm
    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.Label1 = New System.Windows.Forms.Label()
        Me.txtTotalSales = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtTotalSalesKwazuluNatal = New System.Windows.Forms.TextBox()
        Me.txtKwazuluNatalPercentages = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.txtTotalSalesGauteng = New System.Windows.Forms.TextBox()
        Me.txtGautengPercentages = New System.Windows.Forms.TextBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.txtTotalSalesWestern = New System.Windows.Forms.TextBox()
        Me.txtWesternPercentages = New System.Windows.Forms.TextBox()
        Me.pbLogo = New System.Windows.Forms.PictureBox()
        CType(Me.pbLogo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(15, 30)
        Me.Label1.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(498, 24)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "The total sales made in there three regions in South Africa:"
        '
        'txtTotalSales
        '
        Me.txtTotalSales.BackColor = System.Drawing.Color.White
        Me.txtTotalSales.Location = New System.Drawing.Point(515, 27)
        Me.txtTotalSales.Name = "txtTotalSales"
        Me.txtTotalSales.ReadOnly = True
        Me.txtTotalSales.Size = New System.Drawing.Size(75, 29)
        Me.txtTotalSales.TabIndex = 1
        Me.txtTotalSales.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(15, 83)
        Me.Label2.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(442, 24)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "The total sales made in the region in Kwazulu-Natal:"
        '
        'txtTotalSalesKwazuluNatal
        '
        Me.txtTotalSalesKwazuluNatal.BackColor = System.Drawing.Color.White
        Me.txtTotalSalesKwazuluNatal.Location = New System.Drawing.Point(515, 80)
        Me.txtTotalSalesKwazuluNatal.Name = "txtTotalSalesKwazuluNatal"
        Me.txtTotalSalesKwazuluNatal.ReadOnly = True
        Me.txtTotalSalesKwazuluNatal.Size = New System.Drawing.Size(75, 29)
        Me.txtTotalSalesKwazuluNatal.TabIndex = 1
        Me.txtTotalSalesKwazuluNatal.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'txtKwazuluNatalPercentages
        '
        Me.txtKwazuluNatalPercentages.BackColor = System.Drawing.Color.White
        Me.txtKwazuluNatalPercentages.Location = New System.Drawing.Point(603, 80)
        Me.txtKwazuluNatalPercentages.Name = "txtKwazuluNatalPercentages"
        Me.txtKwazuluNatalPercentages.ReadOnly = True
        Me.txtKwazuluNatalPercentages.Size = New System.Drawing.Size(75, 29)
        Me.txtKwazuluNatalPercentages.TabIndex = 1
        Me.txtKwazuluNatalPercentages.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(594, 32)
        Me.Label3.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(121, 24)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Percentages:"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(15, 118)
        Me.Label4.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(395, 24)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "The total sales made in the region in Gauteng:"
        '
        'txtTotalSalesGauteng
        '
        Me.txtTotalSalesGauteng.BackColor = System.Drawing.Color.White
        Me.txtTotalSalesGauteng.Location = New System.Drawing.Point(515, 115)
        Me.txtTotalSalesGauteng.Name = "txtTotalSalesGauteng"
        Me.txtTotalSalesGauteng.ReadOnly = True
        Me.txtTotalSalesGauteng.Size = New System.Drawing.Size(75, 29)
        Me.txtTotalSalesGauteng.TabIndex = 1
        Me.txtTotalSalesGauteng.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'txtGautengPercentages
        '
        Me.txtGautengPercentages.BackColor = System.Drawing.Color.White
        Me.txtGautengPercentages.Location = New System.Drawing.Point(603, 115)
        Me.txtGautengPercentages.Name = "txtGautengPercentages"
        Me.txtGautengPercentages.ReadOnly = True
        Me.txtGautengPercentages.Size = New System.Drawing.Size(75, 29)
        Me.txtGautengPercentages.TabIndex = 1
        Me.txtGautengPercentages.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(15, 153)
        Me.Label5.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(442, 24)
        Me.Label5.TabIndex = 0
        Me.Label5.Text = "The total sales made in the region in Kwazulu-Natal:"
        '
        'txtTotalSalesWestern
        '
        Me.txtTotalSalesWestern.BackColor = System.Drawing.Color.White
        Me.txtTotalSalesWestern.Location = New System.Drawing.Point(515, 150)
        Me.txtTotalSalesWestern.Name = "txtTotalSalesWestern"
        Me.txtTotalSalesWestern.ReadOnly = True
        Me.txtTotalSalesWestern.Size = New System.Drawing.Size(75, 29)
        Me.txtTotalSalesWestern.TabIndex = 1
        Me.txtTotalSalesWestern.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'txtWesternPercentages
        '
        Me.txtWesternPercentages.BackColor = System.Drawing.Color.White
        Me.txtWesternPercentages.Location = New System.Drawing.Point(603, 150)
        Me.txtWesternPercentages.Name = "txtWesternPercentages"
        Me.txtWesternPercentages.ReadOnly = True
        Me.txtWesternPercentages.Size = New System.Drawing.Size(75, 29)
        Me.txtWesternPercentages.TabIndex = 1
        Me.txtWesternPercentages.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'pbLogo
        '
        Me.pbLogo.BackgroundImage = Global.ITI_Hub_Sales_Amount.My.Resources.Resources.sales
        Me.pbLogo.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.pbLogo.Location = New System.Drawing.Point(722, 32)
        Me.pbLogo.Name = "pbLogo"
        Me.pbLogo.Size = New System.Drawing.Size(193, 147)
        Me.pbLogo.TabIndex = 2
        Me.pbLogo.TabStop = False
        '
        'mainForm
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(11.0!, 24.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(942, 204)
        Me.Controls.Add(Me.pbLogo)
        Me.Controls.Add(Me.txtWesternPercentages)
        Me.Controls.Add(Me.txtTotalSalesWestern)
        Me.Controls.Add(Me.txtGautengPercentages)
        Me.Controls.Add(Me.txtTotalSalesGauteng)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.txtKwazuluNatalPercentages)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.txtTotalSalesKwazuluNatal)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.txtTotalSales)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label1)
        Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, 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(6, 6, 6, 6)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "mainForm"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "ITI Hub Sales Amount"
        CType(Me.pbLogo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()


    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtTotalSales As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtTotalSalesKwazuluNatal As System.Windows.Forms.TextBox
    Friend WithEvents txtKwazuluNatalPercentages As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtTotalSalesGauteng As System.Windows.Forms.TextBox
    Friend WithEvents txtGautengPercentages As System.Windows.Forms.TextBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents txtTotalSalesWestern As System.Windows.Forms.TextBox
    Friend WithEvents txtWesternPercentages As System.Windows.Forms.TextBox
    Friend WithEvents pbLogo As System.Windows.Forms.PictureBox


End Class




Public Class mainForm


    Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Store the sales amount in a two-dimensional array. 
        Dim salesAmount(,) As Integer = {{120000, 190000, 175000, 188000, 125000, 163000},
                                     {90000, 85000, 80000, 83000, 87000, 80000},
                                     {65000, 64000, 71000, 67000, 65000, 64000}}


        Dim totalSales As Integer = 0
        Dim totalSalesKwazuluNatal As Integer = 0
        Dim kwazuluNatalPercentages As Integer = 0
        Dim totalSalesGauteng As Integer = 0
        Dim gautengPercentages As Integer = 0
        Dim totalSalesWestern As Integer = 0
        Dim westernPercentages As Integer = 0


        For i As Integer = 0 To 2
            For j As Integer = 0 To 5
                totalSales += salesAmount(i, j)
            Next
        Next


        For j As Integer = 0 To 5
            totalSalesKwazuluNatal += salesAmount(0, j)
            totalSalesGauteng += salesAmount(1, j)
            totalSalesWestern += salesAmount(2, j)
        Next


        kwazuluNatalPercentages = (totalSalesKwazuluNatal / totalSales) * 100
        gautengPercentages = (totalSalesGauteng / totalSales) * 100
        westernPercentages = (totalSalesWestern / totalSales) * 100


        txtTotalSales.Text = Math.Ceiling(totalSales).ToString()
        txtTotalSalesKwazuluNatal.Text = Math.Ceiling(totalSalesKwazuluNatal).ToString()
        txtKwazuluNatalPercentages.Text = Math.Ceiling(kwazuluNatalPercentages).ToString() + "%"
        txtTotalSalesGauteng.Text = Math.Ceiling(totalSalesGauteng).ToString()
        txtGautengPercentages.Text = Math.Ceiling(gautengPercentages).ToString() + "%"
        txtTotalSalesWestern.Text = Math.Ceiling(totalSalesWestern).ToString()
        txtWesternPercentages.Text = Math.Ceiling(westernPercentages).ToString() + "%"


    End Sub
End Class


Image:




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
APPROVED BY CLIENTS