Visual Basic Help with coding?
-
Here's the problem: A local recording studio rents its facilities for $200 per hour, but charges only for the number of minutes used. Your form should allow input of the name of the group and the number of minutes used in the studio. Your program should calculate (and display) the recording charge for this session, as well as accumulate the total charges for all groups. Display summary information in a group box. Display the total charges for all groups, the total number of groups, and the average charge per group. Format all output appropriately. Include Calculate, Clear for Next Group (does not clear summary info), and Exit buttons. Do not allow bad input to cancel the program. I have the form all made up, I just need help figuring out the coding for the calculations. This is my coding so far for my claculations Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click 'Calculate the price Dim MinutesUsedInteger, TotalChargesInteger As Integer Dim AmountDue, AverageCharge As Decimal Try 'Convert minutes used to numeric variable MinutesUsedInteger = Integer.Parse(MinutesUsedTextBox.Text) Try 'convert price if minutes used was successful AmountDue = Decimal.Parse(AmountDueTextBox.Text) 'Calculate values for sale AmountDue = MinutesUsedInteger * CHARGE_PER_HOUR 'calculate summary values TotalChargesSumInteger += TotalChargesInteger TotalNumberOfGroups += 1 AverageCharge = TotalChargesSumInteger / TotalNumberOfGroups 'Format and Display answers for the sale AmountDueTextBox.Text = AmountDue.ToString("C") 'Format and Display summary values TotalChargesTextBox.Text = NumberOfGroupsTextBox.Text= AverageChargeTextBox.Text = TotalChargeAllGroupsTextBox.Text= Catch ex As Exception End Try Catch ex As Exception Catch AnException As Exception ' Handle any other exception MessageBox.Show("Error: " & AnException.Message) End Try End Sub End Class
-
Answer:
The biggest point of the calculations is that they only get charged foe the minutes they used, but the prices are based on the hour. To get the correct total: Dim totalHours As Integer Dim totalMinutes As Integer totalHours = minutesUsedInteger / 60 'Finds the integer number of hours totalMinutes = MinutesUsedInteger Mod 60 'Finds the extra minutes AmountDue = (totalHours * CHARGE_PER_HOUR) + (totalMinutes * (CHARGE_PER_HOUR / 60))
tigerang... at Yahoo! Answers Visit the source
Related Q & A:
- What are the object-oriented features of Visual Basic.NET?Best solution by msdn.microsoft.com
- Can you program Graphics with Visual Basic?Best solution by Yahoo! Answers
- What are the main parts of visual basic 2005?Best solution by msdn.microsoft.com
- Codes for a simple visual basic program.Best solution by vbtutor.net
- How do you use the Contains Function in Visual Basic?Best solution by go4expert.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.