Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I WANT THIS CODE ONLY IN VISUAL BASIC The Middletown Wire Company sells spools o

ID: 3717601 • Letter: I

Question

I WANT THIS CODE ONLY IN VISUAL BASIC

The Middletown Wire Company sells spools of copper wiring for $100 each. The normal deliver charge is $10 per spool. Rush delivery costs $15 per spool. Create an application that displays the status of an order. The status should include the following:

The number of spools ready to ship.

The number of spools on back order.

The shipping and handling charges.

The total amount due.

The application’s form should resemble the one below:

The user should enter the number of spools ordered into the text box, and check the Rush Delivery check box if rush delivery is desired. When the Calculate Total button is clicked, an input box should appear asking the user to enter the number of spools currently in stock. If the user has ordered more spools than are in stock, a portion of the order is back-ordered. For example, if the user orders 200 spools and there are only 150 spools in stock, then 150 spools are ready to ship and 50 spools are back-ordered.

The application should have the following functions, called from the Calculate Total button’s Click event procedure:

GetInStock              
Displays an input box asking the user to enter the number of spools in stock. The function should return the value entered by the user.

ReadyToShip
Accepts the following arguments: the number of spools in stock and the number of spools ordered. The function returns the number of spools ready to ship.

BackOrdered
Accepts the following arguments: the number of spools in stock and the number of spools ordered. The function returns the number of spools on back order. If no spools are on back order, it returns 0.

ShippingCharges
Accepts the following arguments: the number of spools ready to ship and the per-spool shipping charges. The function returns the total shipping and handling charges.

The application should have the following procedures, called from the Clear Form button’s Click event procedure:

ResetSpools
Clears the text box and the check box.

ResetDelivery
Clears the labels that display the delivery information.

Input Validation: Do not accept orders for less than one spool.

Order Status Order Information Spools raer of Spools Ordered Rush Delivery Delivery Information Spools Ready to Ship: Spools on Back Order. ripirngg Total Due: Calculate Ttl Clear Form lxit

Explanation / Answer

Answer :

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

Partial Class Order
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.Panel1 = New System.Windows.Forms.Panel()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.rush = New System.Windows.Forms.CheckBox()
Me.spools = New System.Windows.Forms.TextBox()
Me.Panel2 = New System.Windows.Forms.Panel()
Me.totaltxt = New System.Windows.Forms.TextBox()
Me.tchargetxt = New System.Windows.Forms.TextBox()
Me.bordertxt = New System.Windows.Forms.TextBox()
Me.readytxt = New System.Windows.Forms.TextBox()
Me.Label8 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.calculate = New System.Windows.Forms.Button()
Me.clear = New System.Windows.Forms.Button()
Me.exitBtn = New System.Windows.Forms.Button()
Me.Panel1.SuspendLayout()
Me.Panel2.SuspendLayout()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 20)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(171, 18)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Number of Spools Ordered:"
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Label3)
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.rush)
Me.Panel1.Controls.Add(Me.spools)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(42, 45)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(316, 109)
Me.Panel1.TabIndex = 1
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(16, 0)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(88, 13)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Order Information"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Palatino Linotype", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Red
Me.Label2.Location = New System.Drawing.Point(30, 43)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(272, 17)
Me.Label2.TabIndex = 3
Me.Label2.Text = "*Number of spools ordered should be at least 1."
Me.Label2.Visible = False
'
'rush
'
Me.rush.AutoSize = True
Me.rush.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rush.Location = New System.Drawing.Point(19, 63)
Me.rush.Name = "rush"
Me.rush.Size = New System.Drawing.Size(112, 22)
Me.rush.TabIndex = 2
Me.rush.Text = "Rush Delivery"
Me.rush.UseVisualStyleBackColor = True
'
'spools
'
Me.spools.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.spools.Location = New System.Drawing.Point(185, 17)
Me.spools.Name = "spools"
Me.spools.Size = New System.Drawing.Size(100, 25)
Me.spools.TabIndex = 1
'
'Panel2
'
Me.Panel2.Controls.Add(Me.totaltxt)
Me.Panel2.Controls.Add(Me.tchargetxt)
Me.Panel2.Controls.Add(Me.bordertxt)
Me.Panel2.Controls.Add(Me.readytxt)
Me.Panel2.Controls.Add(Me.Label8)
Me.Panel2.Controls.Add(Me.Label7)
Me.Panel2.Controls.Add(Me.Label6)
Me.Panel2.Controls.Add(Me.Label5)
Me.Panel2.Controls.Add(Me.Label4)
Me.Panel2.Location = New System.Drawing.Point(45, 169)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(313, 159)
Me.Panel2.TabIndex = 2
'
'totaltxt
'
Me.totaltxt.Enabled = False
Me.totaltxt.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.totaltxt.Location = New System.Drawing.Point(182, 110)
Me.totaltxt.Name = "totaltxt"
Me.totaltxt.Size = New System.Drawing.Size(100, 25)
Me.totaltxt.TabIndex = 8
'
'tchargetxt
'
Me.tchargetxt.Enabled = False
Me.tchargetxt.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.tchargetxt.Location = New System.Drawing.Point(182, 80)
Me.tchargetxt.Name = "tchargetxt"
Me.tchargetxt.Size = New System.Drawing.Size(100, 25)
Me.tchargetxt.TabIndex = 7
'
'bordertxt
'
Me.bordertxt.Enabled = False
Me.bordertxt.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bordertxt.Location = New System.Drawing.Point(182, 50)
Me.bordertxt.Name = "bordertxt"
Me.bordertxt.Size = New System.Drawing.Size(100, 25)
Me.bordertxt.TabIndex = 6
'
'readytxt
'
Me.readytxt.Enabled = False
Me.readytxt.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.readytxt.Location = New System.Drawing.Point(182, 20)
Me.readytxt.Name = "readytxt"
Me.readytxt.Size = New System.Drawing.Size(100, 25)
Me.readytxt.TabIndex = 5
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label8.Location = New System.Drawing.Point(98, 113)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(68, 18)
Me.Label8.TabIndex = 4
Me.Label8.Text = "Total Due:"
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(39, 83)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(127, 18)
Me.Label7.TabIndex = 3
Me.Label7.Text = "Shipping & Handling:"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(28, 53)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(138, 18)
Me.Label6.TabIndex = 2
Me.Label6.Text = "Spools on Back Order:"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(30, 23)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(136, 18)
Me.Label5.TabIndex = 1
Me.Label5.Text = "Spools Ready to Ship:"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(16, 0)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(100, 13)
Me.Label4.TabIndex = 0
Me.Label4.Text = "Delivery Information"
'
'calculate
'
Me.calculate.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.calculate.Location = New System.Drawing.Point(45, 332)
Me.calculate.Name = "calculate"
Me.calculate.Size = New System.Drawing.Size(121, 30)
Me.calculate.TabIndex = 3
Me.calculate.Text = "Calculate Total"
Me.calculate.UseVisualStyleBackColor = True
'
'clear
'
Me.clear.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.clear.Location = New System.Drawing.Point(172, 332)
Me.clear.Name = "clear"
Me.clear.Size = New System.Drawing.Size(101, 30)
Me.clear.TabIndex = 4
Me.clear.Text = "Clear Form"
Me.clear.UseVisualStyleBackColor = True
'
'exitBtn
'
Me.exitBtn.Font = New System.Drawing.Font("Palatino Linotype", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.exitBtn.Location = New System.Drawing.Point(279, 332)
Me.exitBtn.Name = "exitBtn"
Me.exitBtn.Size = New System.Drawing.Size(79, 30)
Me.exitBtn.TabIndex = 5
Me.exitBtn.Text = "Exit"
Me.exitBtn.UseVisualStyleBackColor = True
'
'Order
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(404, 403)
Me.Controls.Add(Me.exitBtn)
Me.Controls.Add(Me.clear)
Me.Controls.Add(Me.calculate)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Panel1)
Me.Name = "Order"
Me.Text = "Order Status"
Me.Panel1.ResumeLayout(False)
Me.Panel1.PerformLayout()
Me.Panel2.ResumeLayout(False)
Me.Panel2.PerformLayout()
Me.ResumeLayout(False)

End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents rush As System.Windows.Forms.CheckBox
Friend WithEvents spools As System.Windows.Forms.TextBox
Friend WithEvents Panel2 As System.Windows.Forms.Panel
Friend WithEvents totaltxt As System.Windows.Forms.TextBox
Friend WithEvents tchargetxt As System.Windows.Forms.TextBox
Friend WithEvents bordertxt As System.Windows.Forms.TextBox
Friend WithEvents readytxt As System.Windows.Forms.TextBox
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents calculate As System.Windows.Forms.Button
Friend WithEvents clear As System.Windows.Forms.Button
Friend WithEvents exitBtn As System.Windows.Forms.Button

Private Sub Order_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub calculate_Click(sender As Object, e As EventArgs) Handles calculate.Click
Dim price As Integer
Dim dCharge As Integer
Dim tCharge As Integer
Dim stock As Integer
Dim bOrdered As Integer
Dim spool As Integer
Dim ready As Integer
Dim total As Integer

price = 100
dCharge = 10
If Val(spools.Text) < 1 Then 'Input validation
Label2.Visible = True
spools.Text = ""
spools.Focus()
Else
spool = Val(spools.Text) 'Reading input
If rush.Checked Then 'If rush delivery then special charge
dCharge = 15
End If
'Calling functions to get values
stock = GetInStock()
ready = ReadyToShip(stock, spool)
bOrdered = BackOrdered(stock, spool)
tCharge = ShippingCharges(ready, dCharge)
'Calculating total
total = (ready * price) + tCharge
'Displaying
readytxt.Text = ready
bordertxt.Text = bOrdered
tchargetxt.Text = "$" & tCharge & ".00"
totaltxt.Text = "$" & total & ".00"

End If

End Sub
Private Function GetInStock() As Integer
GetInStock = Val(InputBox("Number of spools currently in stock:", "Current Stock"))
End Function
Private Function ReadyToShip(stock As Integer, spool As Integer) As Integer
ReadyToShip = stock
End Function

Private Function BackOrdered(stock As Integer, spool As Integer)
BackOrdered = spool - stock
End Function

Private Function ShippingCharges(ready As Integer, dCharge As Integer) As Integer
ShippingCharges = ready * dCharge
End Function

Private Sub clear_Click(sender As Object, e As EventArgs) Handles clear.Click
'To reset
Call ResetSpools()
Call ResetDelivery()
End Sub
Private Function ResetSpools()
spools.Text = ""
rush.Checked = False
Label2.Visible = False
End Function
Private Function ResetDelivery()
readytxt.Text = ""
bordertxt.Text = ""
tchargetxt.Text = ""
totaltxt.Text = ""
End Function

Private Sub exitBtn_Click(sender As Object, e As EventArgs) Handles exitBtn.Click
Me.Close() 'To exit
End Sub
End Class