|
-
Sep 1st, 2012, 02:55 PM
#1
Thread Starter
New Member
Help !! Programming assignment
Help !! Programming assignment
8. If the user leaves the Customer, Hours, or Parts textboxes blank, produce an error message (using a MessageBox) that informs the user to enter the appropriate information and do not display the information in the listbox.
9. Create variables to hold the customer, phone, hours, and parts information. Name the variables customer, phone, hours, and parts. Their data types should be string, string, double, and double, respectively.
10. When the user clicks the Display Bill button, prompt the user to enter in the date of the services. Store this information in a variable called service_date. Display this date and the date the invoice is due (30 days from the date entered) in the listbox as shown below. [Hint: use the AddDays function]. Store the due date in a variable called due_date.
11. Convert the customer name variable to upper case before displaying it in the listbox.
12. Whenever the user clicks the Display Bill button, the listbox should be cleared before displaying the new results.
13. To calculate the amounts, create three variables (labor_cost, parts_cost, and total_cost), and display these amounts in the listbox as shown below.
14. Be sure to use currency format where appropriate.
15. Be sure that the columns line up appropriately. [Hint: you can use the built-in Visual Basic constant “vbTab” to create neat columns in your listbox.]
THE FOLLOWING IS WHAT I DID BUT I AM GETTING AN ERROR
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayBill.Click
Dim Customer As String
Dim Phone As String
Dim Hours As Double
Dim Parts As Double
If txtCustomer.Text.Length = 0 AndAlso
txtHours.Text.Length < 0 AndAlso txtParts.Text.Length = 0 Then
'display an instructive MessageBox
MessageBox.Show("Please enter the appropriate information in the empty boxes! Please" & vbCrLf & "complete the empty boxes.", "Illegal operation", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
Else
' Do Calculations
Customer = CStr(txtCustomer.Text)
Phone = CStr(mtbPhone.Text)
Hours = CDbl(txtHours.Text)
Parts = CDbl(txtParts.Text)
lstBill.Items.Clear()
lstBill.Items.Add("Customer:" & Customer)
lstBill.Items.Add("Phone:" & Phone)
lstBill.Items.Add("Hours Cost:" & Hours * 35)
lstBill.Items.Add("Parts Cost:" & Parts * 0.05)
lstBill.Items.Add("Total Cost:" & Hours * 35 + Parts * 0.05)
End If
End Sub
End Class
PLEASEEEEEEE HELP!!!
-
Sep 2nd, 2012, 04:38 AM
#2
Re: Help !! Programming assignment
If txtCustomer.Text.Length = 0 AndAlso
txtHours.Text.Length < 0 AndAlso txtParts.Text.Length = 0 Then
txtHours.Text.Length will never be LESS THAN 0.
11. Convert the customer name variable to upper case before displaying it in the listbox.
In VB.NET, you can use ToUpper, UCase or StrConv
14. Be sure to use currency format where appropriate.
FormatCurrency.
When you post, it is a good idea to put CODE tags round your code to make it much easier to read. Also, don't say, " I AM GETTING AN ERROR". You need to specify what the error is and on which line it is occurring. Failure to provide a clear description of your needs leads to confusion and very often incorrect advice.
-
Sep 2nd, 2012, 06:35 AM
#3
Re: Help !! Programming assignment
 Originally Posted by españolito
In VB.NET, you can use ToUpper, UCase or StrConv
UCase and StrConv are VB6 holdovers. Use ToUpper only.
 Originally Posted by españolito
FormatCurrency.
Another VB6 holdover. Call the ToString method of the number to create a String representation. If you want a specific format then provide the appropriate format specifier. For currency, that would be "c".
-
Sep 2nd, 2012, 09:01 AM
#4
Re: Help !! Programming assignment
Thank you JMc. I am assuming you are so against VB6 legacy because it is likely to be unsupported at some point. Sticking to the pure .Net, means the code will be current for much longer. A valid reason I think.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|