105k views
5 votes
Part cost Calculator Modify the GUI in your program to look like the following GUI. To do that you need to add the following to the GUI in the starter program. A text box to accept the part number (Only one is allowed A1B) Note the user may enter spaces before or after the part number and may enter the letters in lower or upper case. You program must accommodate that.

User Tany
by
7.8k points

1 Answer

6 votes

Answer:

Imports System.Text.RegularExpressions

Public Class Form2

Private Shared Function Num1(ByVal val As String) As Integer

Dim retrnVal As String = String.Empty

Dim collect As MatchCollection = Regex.Matches(val, "\d+")

For Each mat As Match In collect

retrnVal += mat.ToString()

Next

Return Convert.ToInt32(retrnVal)

End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

TextBox1.Text = Num1(TextBox1.Text)

Dim Total As Integer = 0

Dim A1b As Integer = Convert.ToInt32(TextBox1.Text)

Label1.Text = 250

Label2.Text = 25

If Convert.ToInt32(TextBox1.Text) = A1b Then

If Convert.ToInt16(Label1.Text) < 10 Then

Total = 10.5 * Convert.ToInt16(Label1.Text)

Else

Total = 8.75 * Convert.ToInt16(Label1.Text)

End If

If CheckBox1.Checked Then

Total = Total + 10

Else

Total = Total + 5

End If

TextBox2.Text = Convert.ToString(Total)

End If

End Sub

Step-by-step explanation:

Please check the answer section and the attachment. Also, please check the method. We have used the regular expression over there. And we have imported the regularexpression library for that. And this is to ensure we can read integer from textbox no matter whether the user inputs empty spaces or characters in lower and upper case in between.

Part cost Calculator Modify the GUI in your program to look like the following GUI-example-1
Part cost Calculator Modify the GUI in your program to look like the following GUI-example-2
Part cost Calculator Modify the GUI in your program to look like the following GUI-example-3
User Diabolist
by
8.3k points