473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Could some one help me Having Major issue with trying to figure out coding buttons

5. When the “Accumulate” button is clicked:
i. You are to keep grand totals for the Hours and Amount Due for each type of Package.
i. This requires three class-level variables for the Hours, i.e. one for the Package A hours, one for the Package B hours, and one for the Package C hours.
ii. Similarly, you will need three class-level variables for the Amounts.
j. Check the RadioButtons to see which Package is selected and add the Hours and Amount Due into the corresponding set of class-level variables.
k. Also, disable the “Accumulate” button.

6. When the “Reset” button is clicked, display a MessageBox asking to verify the reset:
l. Include “OK” and “CANCEL” buttons.
m. If “OK” clicked, then:
i. Clear all Textboxes & Labels.
ii. Reset all RadioButtons & CheckBoxes.
iii. Reset the title bar to its original value.
iv. Enable the “Validate” button.
v. Disable the “Calculate” and “Accumulate” buttons.
n. If “CANCEL” clicked, then leave the form alone and exit.

7. When the “Exit” button is clicked:
o. Use a MessageBox to display the grand totals for each type of Package.
p. Close the form.




that is what I need to do and this is what I have.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub btnCustomer_Click(sender As Object, e As EventArgs) Handles btnCustomer.Click
  2.         btnCustomer.Enabled = True
  3.         btnCharges.Enabled = False
  4.         Dim lastName As String = Nothing
  5.         Dim spaceCharPos As Integer = txtName.Text.IndexOf(" ")
  6.         If spaceCharPos > -1 Then
  7.             lastName = txtName.Text.Substring(spaceCharPos)
  8.         End If
  9.         If txtName.Text = String.Empty Then
  10.             MessageBox.Show("Please enter your first and last name.")
  11.             txtName.Focus()
  12.         End If
  13.  
  14.  
  15.         If txtName.Text.IndexOf(" ") = -1 Then
  16.             MessageBox.Show("Please put a space between First and Last name.")
  17.         End If
  18.  
  19.         Dim city As String = Nothing
  20.         Dim commaCharPos As Integer = txtCityState.Text.IndexOf(",")
  21.         If commaCharPos > -1 Then
  22.             city = txtCityState.Text.Substring(0, commaCharPos)
  23.         End If
  24.         If txtCityState.Text = String.Empty Then
  25.             MessageBox.Show("Please enter your City and State")
  26.             txtCityState.Focus()
  27.         End If
  28.  
  29.  
  30.         If txtCityState.Text.IndexOf(",") = -1 Then
  31.             MessageBox.Show("Please insert a comma between Clity & State.")
  32.         End If
  33.  
  34.         Me.Text = lastName & " from " & city
  35.         btnCustomer.Enabled = False
  36.         btnCharges.Enabled = True
  37.         btnTotals.Enabled = True
  38.  
  39.     End Sub
  40.     Private Sub btnCharges_Click(sender As Object, e As EventArgs) Handles btnCharges.Click
  41.         btnCharges.Enabled = True
  42.         btnCustomer.Enabled = False
  43.  
  44.         Dim decTotal As Decimal
  45.         Dim intHours As Integer
  46.         Const decNonProfit As Decimal = 0.8D
  47.  
  48.             intHours = CInt(txtHours.Text)
  49.  
  50.             If CInt(txtHours.Text) > 744 Then
  51.                 MessageBox.Show("Monthly Hours Can't Exceed 744")
  52.                 txtHours.Text = String.Empty
  53.                 lblAmountDue.Text = String.Empty
  54.             End If
  55.             If radA.Checked = False Then
  56.             ElseIf radB.Checked = False Then
  57.             ElseIf radC.Checked = False Then
  58.  
  59.                 MessageBox.Show("Please select an internet package to proceed")
  60.                 btnTotals.Enabled = False
  61.             End If
  62.  
  63.  
  64.  
  65.             If radA.Checked Then
  66.                 If intHours > 10 Then
  67.                     decTotal = CDec((9.95 + ((intHours - 10) * 2)))
  68.                 ElseIf intHours <= 10 Then
  69.                     decTotal = CDec(9.95)
  70.                 End If
  71.             End If
  72.  
  73.             If radB.Checked Then
  74.                 If intHours > 20 Then
  75.                     decTotal = CDec((14.95 + ((intHours - 20) * 1)))
  76.                 ElseIf intHours <= 20 Then
  77.                     decTotal = CDec(14.95)
  78.                 End If
  79.         End If
  80.  
  81.             If radC.Checked Then
  82.                 decTotal = CDec(19.95)
  83.             End If
  84.  
  85.             If chkNonProfit.Checked = True Then
  86.                 decTotal = decTotal * decNonProfit
  87.  
  88.             End If
  89.  
  90.             lblAmountDue.Text = decTotal.ToString("c")
  91.  
  92.     End Sub
  93.  
  94.     Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
  95.         radA.Checked = False
  96.         radB.Checked = False
  97.         radC.Checked = False
  98.         chkNonProfit.Checked = False
  99.         lblAmountDue.Text = String.Empty
  100.         txtHours.Text = String.Empty
  101.         txtName.Clear()
  102.         txtCityState.Clear()
  103.         txtName.Focus()
  104.         btnCustomer.Enabled = True
  105.         btnCharges.Enabled = False
  106.         btnTotals.Enabled = False
  107.         VarGetInput()
  108.     End Sub
  109.  
  110.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  111.         Dim GrandTotal As Integer
  112.         Dim decPackA, decPackB, decPackC As Decimal
  113.  
  114.         GrandTotal = CInt(decPackA + decPackB + decPackC)
  115.  
  116.         GrandTotal = CInt("Package A: " & decPackA.ToString("c"))
  117.         GrandTotal = CInt("Package B: " & decPackB.ToString("c"))
  118.         GrandTotal = CInt("Package C: " & decPackC.ToString("c"))
  119.         GrandTotal = CInt("Grand Total:" & GrandTotal.ToString("C"))
  120.  
  121.     End Sub
  122. End Class
Mar 14 '16 #1
13 1720
Luk3r
300 256MB
You have not stated what kind of error you're getting, what's not working, or where exactly in the code you're having an issue. A little more detail would be mighty helpful.


You also have quite a bit of cleanup that can be done to make your code easier to look at to decipher what's going on. See below for examples:


This:
Expand|Select|Wrap|Line Numbers
  1. If radA.Checked = False Then
  2.  ElseIf radB.Checked = False Then
  3.  ElseIf radC.Checked = False Then
  4.  
  5.  MessageBox.Show("Please select an internet package to proceed")
  6.  btnTotals.Enabled = False
  7.  End If
To This:
Expand|Select|Wrap|Line Numbers
  1. If radA.Checked = False andAlso radB.Checked = False andAlso radC.Checked = False Then
  2.   MessageBox.Show("Please select an internet package to proceed")
  3.   btnTotals.Enabled = False
  4. End If
and This:
Expand|Select|Wrap|Line Numbers
  1. If radA.Checked Then
  2.  If intHours > 10 Then
  3.  decTotal = CDec((9.95 + ((intHours - 10) * 2)))
  4.  ElseIf intHours <= 10 Then
  5.  decTotal = CDec(9.95)
  6.  End If
  7.  End If
  8.  
  9.  If radB.Checked Then
  10.  If intHours > 20 Then
  11.  decTotal = CDec((14.95 + ((intHours - 20) * 1)))
  12.  ElseIf intHours <= 20 Then
  13.  decTotal = CDec(14.95)
  14.  End If
  15.  End If
  16.  
To This:
Expand|Select|Wrap|Line Numbers
  1. If radA.Checked andAlso intHours > 10 Then
  2.   decTotal = CDec((9.95 + ((intHours - 10) * 2)))
  3. ElseIf radA.Checked andAlso intHours <= 10 Then
  4.   decTotal = CDec(9.95)
  5. End If
  6.  
  7. If radB.Checked andAlso intHours > 20 Then
  8.   decTotal = CDec((14.95 + ((intHours - 20) * 1)))
  9. ElseIf radB.Checked andAlso intHours <= 20 Then
  10.   decTotal = CDec(14.95)
  11. End If
Mar 14 '16 #2
I think I figured out the getting a messagebox to work on my reset button but I am new to this and cannot seem to figure out a how to get the code the calculations on the accumulate and how to get the grand total working on the exit button for a message box. I am not using the right coding for any so the error messages are multiple. Like Conversion from string "Package A: $0.00" to type 'Integer' is not valid.
Mar 14 '16 #3
thank you for that much easier and help more on it making sense
Mar 14 '16 #4
Luk3r
300 256MB
No problem. Your exit button can be cleaned up by doing the following, but please note, you're not actually specifying amounts for deckPackA, B, or C anywhere in your code:

Expand|Select|Wrap|Line Numbers
  1. MsgBox("Package A: " & decPackA & "c" & vbCrLf & "Package B: " & decPackB & "c" & vbCrLf & "Package C: " & decPackC & "c" & vbCrLf & "Grand Total: " & GrandTotal & "C")
Mar 14 '16 #5
I know that is where the accumulate button comes in and I don't know how to do that.

When the “Accumulate” button is clicked:
i. You are to keep grand totals for the Hours and Amount Due for each type of Package.
i. This requires three class-level variables for the Hours, i.e. one for the Package A hours, one for the Package B hours, and one for the Package C hours.
ii. Similarly, you will need three class-level variables for the Amounts.
j. Check the RadioButtons to see which Package is selected and add the Hours and Amount Due into the corresponding set of class-level variables.
k. Also, disable the “Accumulate” button.
Mar 14 '16 #6
Luk3r
300 256MB
I will try to find some time to help tomorrow unless someone else steps in. I don't have Visual Studio on my computer at home and my work day is over. Good luck and keep me up-to-date if you make any progress!
Mar 14 '16 #7
I will do that and Thank you very much for your help
Mar 14 '16 #8
Luk3r
300 256MB
Good morning, ldelvoye. Below should help you in moving forward.

First things first, you need to declare 7 class variables. Three for package totals, three for package hours, and one for the grandtotal of cost. That would look like this:
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim decPackA As Integer
  3.     Dim decPackB As Integer
  4.     Dim decPackC As Integer
  5.     Dim decPackAHours As Integer
  6.     Dim decPackBHours As Integer
  7.     Dim decPackCHours As Integer
  8.     Dim GrandTotal As Integer
Next, you need to know what to do with those variables. You need to manipulate them by always making them larger each time the btnCharges button is clicked. Like this:
Expand|Select|Wrap|Line Numbers
  1.         If radA.Checked AndAlso intHours > 10 Then
  2.             decTotal = CDec((9.95 + ((intHours - 10) * 2)))
  3.             decPackA = decPackA + decTotal
  4.             decPackAHours = decPackAHours + intHours
  5.         ElseIf radA.Checked AndAlso intHours <= 10 Then
  6.             decTotal = CDec(9.95)
  7.             decPackA = decPackA + decTotal
  8.             decPackAHours = decPackAHours + intHours
  9.         End If
  10.  
  11.         If radB.Checked AndAlso intHours > 20 Then
  12.             decTotal = CDec((14.95 + ((intHours - 20) * 1)))
  13.             decPackB = decPackB + decTotal
  14.             decPackBHours = decPackBHours + intHours
  15.         ElseIf radB.Checked AndAlso intHours <= 20 Then
  16.             decTotal = CDec(14.95)
  17.             decPackB = decPackB + decTotal
  18.             decPackBHours = decPackBHours + intHours
  19.         End If
Then, in your accumulate button and exit button, you need to specify the grandTotal, by adding decPackA, B, and C, throw a MsgBox with that data, and close the form. Like this:
Expand|Select|Wrap|Line Numbers
  1.         GrandTotal = decPackA + decPackB + decPackC
  2.         MsgBox("Package A: " & decPackA.ToString("c") & vbCrLf & "Package A Hours: " & decPackAHours & vbCrLf & "Package B: " & decPackB.ToString("c") & vbCrLf & "Package B Hours: " & decPackBHours & vbCrLf & "Package C: " & decPackC.ToString("c") & vbCrLf & "Package C Hours: " & decPackCHours & vbCrLf & "Grand Total: " & GrandTotal.ToString("c"))
  3.         Me.Close()
One other thing you would be wise to do is, if you have a messagebox throwing an "error" to the end user because they forgot to fill out data, you should exit the sub routine so that the code does not keep running when it should actually be exiting. I added a little bit of error handling to one of your sections of code so you can see what I'm talking about. Like this:
Expand|Select|Wrap|Line Numbers
  1.         If (txtHours.Text.Length > 0) Then
  2.             intHours = CInt(txtHours.Text)
  3.         Else
  4.             MsgBox("Please enter an amount of hours")
  5.             Exit Sub
  6.         End If
I hope all of this helps! If you need any more help, please feel free to keep posting.
Mar 15 '16 #9
That is good but I do not need to have a messagebox in my accumulate button I just need it to accumulate the packages choose then show up in a messagebox when you exit. Here is an idea of how it is to end up.

Grand Total
PackageA = 40hours for $55.95
PackageB = 0hours for $0.00
PackageC = 10hours for $19.95
Mar 15 '16 #10
Luk3r
300 256MB
So, should you click accumulate after every time you click btnCharges? If so, I've given you plenty of data to work your way to that result.
Mar 15 '16 #11
I am not sure I am totally confuse with this stuff but I don't think so this is what it tells me to do

When the “Accumulate” button is clicked:
i. You are to keep grand totals for the Hours and Amount Due for each type of Package.
i. This requires three class-level variables for the Hours, i.e. one for the Package A hours, one for the Package B hours, and one for the Package C hours.
ii. Similarly, you will need three class-level variables for the Amounts.
j. Check the RadioButtons to see which Package is selected and add the Hours and Amount Due into the corresponding set of class-level variables.
k. Also, disable the “Accumulate” button.
Mar 15 '16 #12
Luk3r
300 256MB
Precisely. So instead of doing the addition to the class variables within the btnCharge click, you must do them when you click the accumulate button. All of the information is in my response for you to move forward. As much as I'd love to do all of your homework, I won't. :)
Mar 15 '16 #13
And I thank you for the help. But I was thinking it was easier than that. So what you are telling me is that what I had in the calculate button is also what goes in the accumulate button. This is what confuses me. Because when you click the calculate btn the amount shows in the amount due label and when you click the accumulate btn it stores it for the exit btn.
Mar 16 '16 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jofio | last post by:
In my frame based page, I have a hyperlink in the top frame called "header" which, when I click, should make two different pages to be loaded and displayed into two different frames, namely...
0
by: Chris | last post by:
Ok, I have the below function in my web app. public void advalue_set_tbs_m (DirectoryEntry ad_user, string field, TextBox tb) { //adds value to AD if value is > 0, if not, sets it to null ...
1
by: Matt | last post by:
Hi, I have a web form where a user can enter child parts for a given parent part. On the top of the page is a text box and a sumbit button labeled "Retrieve Child Parts". When type some part...
9
by: Tim Frawley | last post by:
I have converted a VB6 application to VB.NET. The old application made extensive use of the Clipboard for copying an Image Name so that it could be pasted into the image capture app when the user...
5
by: ilive52 | last post by:
i did some work on ms access at school and then wanted to send it home. i dint have access on the computer so proceeded to install it. having gone through all the neccesary things to do i tried...
0
by: veenala | last post by:
Hi, Iam using image type input button in an application: <form> <input type = "image" id = "back" name= "back" alt = "back" src = "graphics\back.png" > </form> While checking for...
5
by: Radu | last post by:
Hi. I need to implement a "phone-book" kind of feature - I have a list of about 50.000 people, and the user should be able to find anyone by typing either the (beginning of the) last name, either...
3
by: DaveJ | last post by:
I have these two related problems. First one is that I have a webservice that returns a DataSet that works the first time I use it, maybe twice, and then after that fails to work for a few...
2
by: J Dillard | last post by:
I am trying to issert an iif expression in a query that looks at a field in another query. I need to have anything that is an "N" return a value of FALSE and anything that is "Y" return a value of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.