Can you help me create this application in VISUAL BASIC. A function and sub proc
ID: 3802263 • Letter: C
Question
Can you help me create this application in VISUAL BASIC. A function and sub procedure must be used. It's an intro class so methods are basic. I need input validation as well.
4) Create an application that when the user clicks a button, call a sub procedure to input a student name, size and quantity of shirts ordered. Write a function to order price based on the rule: If the size is Small or Medium, the price is $10 per shirt, otherwise the price is $12.00 per shirt. output to a label as shown using a sub procedure. se input validation where necessary) Your calls to your sub procedures and a function should look like this: Dim name as String Dim size as String Dim qty as Integer Dim price as Double InputshirtInfo (name, size, qty) price Calc Price (size, qty) OutputorderInfo (name, price) Your input and output should look like this: Orders Student Name: Size Quantity Problem 4 Bill Smith Medium X-Large Quit The student BILL SMITH owes $36.00.Explanation / Answer
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Name As String
Dim size As String
Dim qty As Integer
Dim price As Double
Name = txtName.Text
size = ComboBox1.SelectedItem
qty = Convert.ToInt16(txtQty.Text)
inputShirtInfo(Name, size, qty)
price = CalcPrice(size, qty)
lblMsg.Text = (Name) + " Price is " + (price).ToString()
End Sub
Function CalcPrice(ByVal size As String, ByVal qty As Integer) As Integer
Dim price As Integer
If (size = "Small " Or size = "Medium") Then
price = 10 * qty
Return price
Else
price = 12 * qty
Return price
End If
End Function
Sub inputShirtInfo(ByVal name As String, ByVal size As String, ByVal qty As Integer)
CalcPrice(size, qty)
End Sub
Sub outputorderinfo(ByVal name As String, ByVal price As Integer)
inputShirtInfo(name, Size.ToString(), txtQty.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
End Class