Answer to Question #189175 in Visual Basic for Mvelo Mashala

Question #189175

Design a Windows application named Wallpaper App to calculate the number of single rolls of wallpaper required to cover a room. There are four combo boxes having a drop down style. Display the range of values for the room’s length, width and height from 10 to 35 in the combo boxes while the value in the combo box for the roll coverage should range from 40 to 50 with an increment of 0.5.


1
Expert's answer
2021-05-05T06:50:27-0400
Public Class frmWallpaperApp


    Private Sub frmWallpaperApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Display the range of values for the room’s length, width and height from 10 to 35 in the combo boxes
        For i As Integer = 10 To 35
            cbLength.Items.Add(i.ToString())
            cbWidth.Items.Add(i.ToString())
            cbHeight.Items.Add(i.ToString())
        Next




        'The value in the combo box for the roll coverage should range from 40 to 50 with an increment of 0.5.
        For i As Decimal = 40 To 50 Step 0.5
            cbRollCoverage.Items.Add(i.ToString())
        Next


        cbLength.SelectedIndex = 0
        cbWidth.SelectedIndex = 0
        cbHeight.SelectedIndex = 0
        cbRollCoverage.SelectedIndex = 0
    End Sub
    ''' <summary>
    ''' Calculate button
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        lblSingleRolls.Text = ""
        Dim roomArea As Integer = 2 * (Integer.Parse(cbHeight.SelectedItem) * Integer.Parse(cbWidth.SelectedItem) +
            Integer.Parse(cbHeight.SelectedItem) * Integer.Parse(cbLength.SelectedItem))
        Dim singleRolls As Double = roomArea / Double.Parse(cbRollCoverage.SelectedItem)
        lblSingleRolls.Text = Math.Ceiling(singleRolls).ToString()
    End Sub


    ''' <summary>
    ''' Exit button
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub


    
End Class







<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmWallpaperApp
    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.cbLength = New System.Windows.Forms.ComboBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.cbWidth = New System.Windows.Forms.ComboBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.cbHeight = New System.Windows.Forms.ComboBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.cbRollCoverage = New System.Windows.Forms.ComboBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.lblSingleRolls = New System.Windows.Forms.Label()
        Me.btnCalculate = New System.Windows.Forms.Button()
        Me.btnExit = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(22, 23)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(70, 13)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Length (feet):"
        '
        'cbLength
        '
        Me.cbLength.FormattingEnabled = True
        Me.cbLength.Location = New System.Drawing.Point(25, 39)
        Me.cbLength.Name = "cbLength"
        Me.cbLength.Size = New System.Drawing.Size(83, 21)
        Me.cbLength.TabIndex = 0
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(111, 23)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(68, 13)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Width (feet): "
        '
        'cbWidth
        '
        Me.cbWidth.FormattingEnabled = True
        Me.cbWidth.Location = New System.Drawing.Point(114, 39)
        Me.cbWidth.Name = "cbWidth"
        Me.cbWidth.Size = New System.Drawing.Size(83, 21)
        Me.cbWidth.TabIndex = 1
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(200, 23)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(68, 13)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Height (feet):"
        '
        'cbHeight
        '
        Me.cbHeight.FormattingEnabled = True
        Me.cbHeight.Location = New System.Drawing.Point(203, 39)
        Me.cbHeight.Name = "cbHeight"
        Me.cbHeight.Size = New System.Drawing.Size(83, 21)
        Me.cbHeight.TabIndex = 2
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(289, 23)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(105, 13)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Roll coverage (sqFt):"
        '
        'cbRollCoverage
        '
        Me.cbRollCoverage.FormattingEnabled = True
        Me.cbRollCoverage.Location = New System.Drawing.Point(292, 39)
        Me.cbRollCoverage.Name = "cbRollCoverage"
        Me.cbRollCoverage.Size = New System.Drawing.Size(83, 21)
        Me.cbRollCoverage.TabIndex = 3
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(22, 79)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(60, 13)
        Me.Label5.TabIndex = 0
        Me.Label5.Text = "Single rolls:"
        '
        'lblSingleRolls
        '
        Me.lblSingleRolls.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblSingleRolls.Location = New System.Drawing.Point(25, 100)
        Me.lblSingleRolls.Name = "lblSingleRolls"
        Me.lblSingleRolls.Size = New System.Drawing.Size(136, 27)
        Me.lblSingleRolls.TabIndex = 2
        Me.lblSingleRolls.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'btnCalculate
        '
        Me.btnCalculate.Location = New System.Drawing.Point(175, 100)
        Me.btnCalculate.Name = "btnCalculate"
        Me.btnCalculate.Size = New System.Drawing.Size(93, 27)
        Me.btnCalculate.TabIndex = 4
        Me.btnCalculate.Text = "&Calculate"
        Me.btnCalculate.UseVisualStyleBackColor = True
        '
        'btnExit
        '
        Me.btnExit.Location = New System.Drawing.Point(274, 100)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(93, 27)
        Me.btnExit.TabIndex = 5
        Me.btnExit.Text = "E&xit"
        Me.btnExit.UseVisualStyleBackColor = True
        '
        'frmWallpaperApp
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(414, 147)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnCalculate)
        Me.Controls.Add(Me.lblSingleRolls)
        Me.Controls.Add(Me.cbRollCoverage)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.cbHeight)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.cbWidth)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.cbLength)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmWallpaperApp"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Wallpaper App "
        Me.ResumeLayout(False)
        Me.PerformLayout()


    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents cbLength As System.Windows.Forms.ComboBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cbWidth As System.Windows.Forms.ComboBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents cbHeight As System.Windows.Forms.ComboBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents cbRollCoverage As System.Windows.Forms.ComboBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents lblSingleRolls As System.Windows.Forms.Label
    Friend WithEvents btnCalculate As System.Windows.Forms.Button
    Friend WithEvents btnExit As System.Windows.Forms.Button


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