Answer to Question #189180 in Visual Basic for Lee

Question #189180

Design a Windows application named Wallpaper App to calculate the number of single rolls of wallpaper required to cover a room


1
Expert's answer
2021-05-05T06:50:31-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.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.btnCalculate = New System.Windows.Forms.Button()
        Me.btnExit = New System.Windows.Forms.Button()
        Me.txtSingleRolls = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(54, 21)
        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(130, 18)
        Me.cbLength.Name = "cbLength"
        Me.cbLength.Size = New System.Drawing.Size(71, 21)
        Me.cbLength.TabIndex = 0
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(54, 60)
        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(130, 57)
        Me.cbWidth.Name = "cbWidth"
        Me.cbWidth.Size = New System.Drawing.Size(71, 21)
        Me.cbWidth.TabIndex = 1
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(54, 100)
        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(130, 97)
        Me.cbHeight.Name = "cbHeight"
        Me.cbHeight.Size = New System.Drawing.Size(71, 21)
        Me.cbHeight.TabIndex = 2
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(19, 142)
        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(130, 139)
        Me.cbRollCoverage.Name = "cbRollCoverage"
        Me.cbRollCoverage.Size = New System.Drawing.Size(71, 21)
        Me.cbRollCoverage.TabIndex = 3
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(240, 60)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(60, 13)
        Me.Label5.TabIndex = 0
        Me.Label5.Text = "Single rolls:"
        '
        'btnCalculate
        '
        Me.btnCalculate.Location = New System.Drawing.Point(259, 110)
        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(358, 110)
        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
        '
        'txtSingleRolls
        '
        Me.txtSingleRolls.Location = New System.Drawing.Point(306, 57)
        Me.txtSingleRolls.Name = "txtSingleRolls"
        Me.txtSingleRolls.Size = New System.Drawing.Size(145, 20)
        Me.txtSingleRolls.TabIndex = 6
        '
        'frmWallpaperApp
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(490, 189)
        Me.Controls.Add(Me.txtSingleRolls)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnCalculate)
        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 btnCalculate As System.Windows.Forms.Button
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents txtSingleRolls As System.Windows.Forms.TextBox


End Class




Public Class mainForm


    Private Sub frmWallpaperApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        For i As Integer = 10 To 35
            cbLength.Items.Add(i.ToString())
            cbWidth.Items.Add(i.ToString())
            cbHeight.Items.Add(i.ToString())
        Next
        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


    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim numberRolls As Double = calculateNumberRolls()
        txtSingleRolls.Text = Math.Ceiling(numberRolls).ToString()
    End Sub




    Private Function calculateRoomArea()
        Return 2 * (Integer.Parse(cbHeight.SelectedItem) * Integer.Parse(cbWidth.SelectedItem) +
           Integer.Parse(cbHeight.SelectedItem) * Integer.Parse(cbLength.SelectedItem))
    End Function


    Private Function calculateNumberRolls()
        Dim roomArea As Integer = calculateRoomArea()
        Return roomArea / Double.Parse(cbRollCoverage.SelectedItem)
    End Function




    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub




End Class







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