Analyse the program and execute it

Assignment Help Programming Languages
Reference no: EM13933075

I am working on a program that I want to use for a simple home energy data information system. I am stuck at trying to

figure out how add an inputbox to the washing machine selection that is in my listbox. I would like to add an inputbox that

allows, (only if the user selects the washing machine) the user to add the amount of water they used in gallons per hour and

how much that water costs per gallon. In addition I can't figure out how to make all of my calculations appear in a column in

my second listbox. The data that I want to appear (as soon as the user enters it) is the appliance that they select, number of

hours they are used per day and the cost. Where I am having trouble at is with the calculations and making them appear in

the listbox without the use of a calculate button control. I want the calculations to be automatic as soon as I as the user would

enter it in the textbox controls. I originally created labels for the data to appear in but I plan to remove them since I really

want the data to appear in the second listbox. Here is the code from the form1.vb:

Public Class Form1

'Class level constants

Const dblHOURS_DAY As Double = 24 'Hours a day

Dim intPowerNeeded As Integer

Private Sub txtCostPerHour_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

txtCostPerHour.TextChanged

'Declare cost per hour

Dim decCostPerHour As Decimal

decCostPerHour = CDec(txtCostPerHour.Text)

If decCostPerHour <= 0 Then

'Display out of range message

MessageBox.Show("Please enter a positive number greater than zero.")

End If

'Displays the inputted data without the use label

lblDisplayKiloWattHourCost.Text = txtCostPerHour.Text

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim decCostPerHour As Decimal

Dim lblDisplayKiloWattHourCost As Decimal

decCostPerHour = CDec(txtCostPerHour.Text)

lblDisplayKiloWattHourCost = CDec(decCostPerHour.ToString("n"))

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

ListBox1.SelectedIndexChanged

Dim strOut As String

strOut = ListBox1.SelectedItem.ToString

'Create the above variable name in the label area where I need this data to be copied to.

End Sub

Private Sub txtNumberOfHours_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

txtNumberOfHours.TextChanged

lblNumberOfHoursDisplay.Text = txtNumberOfHours.Text

Dim intNumberOfHoursDisplay As Integer

Dim intCostDisplay As Integer

intNumberOfHoursDisplay = CInt(txtNumberOfHours.Text)

intCostDisplay = intNumberOfHoursDisplay * intPowerNeeded

End Sub

Private Sub strSelectedItemFromListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles strOut.SelectedIndexChanged

strOut.Text = lblCostDisplay.Text

End Sub

Private Sub txtPowerNeeded_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

txtPowerNeeded.TextChanged

intPowerNeeded = CInt(txtPowerNeeded.Text)

lblCostDisplay.Text = CStr(intPowerNeeded)

End Sub

End Class

Attachment:- Form1.zip

Reference no: EM13933075

Questions Cloud

Social roles in the health care : How can socialisation and role theory be applied to relationships in health care between patients/clients and health care workers? firstly describe the key principles of the theory and then give examples of its application in the caring profession..
Find the moment of inertia of the system : Two particles with masses 2.3 kg and 6.6 kg are connected by a light rod of length 3.5 m. Find the moment of inertia of the system about an axis perpendicular to the rod and passing through:
What is the purchase price of the wine : WSM Wine Importers, Inc. purchased 75,000 cases of French wine at a cost of 6,000,000 Euros. If the current exchange rate is 0.7576 Euros to the U.S. dollar, what is the purchase price of the wine in U.S. DOLLARS?
Uses the straight-line method of depreciation : On January 1, 2015, Jek Corporation acquired equipment for $260,000. The estimated life of the equipment is 5 years or 40,000 hours. The estimated salvage value is $20,000. What is the book value of the asset on December 31, 2016 after two years of r..
Analyse the program and execute it : I am working on a program that I want to use for a simple home energy data information system.
New agent of socialisation : Explain how a generation that has been brought up with the Internet and the use of social media might have been socialised differently than their parents or grandparents? Are we faced with a new agent of socialisation? [Speak to your elders if you..
Briefly discuss the pros and cons of the five you chose : Your textbook names several types of criminal justice technology that are currently on the drawing board. Name five of them and provide a short definition. Briefly discuss the pros and cons of the five you chose. Why is it unlikely that plea bar..
What is the cost assigned to the equipment : Land, buildings and equipment are acquired for a lump sum of $875,000. The market values of the three assets are, respectively, $200,000, $500,000 and $300,000. What is the cost assigned to the equipment?
What will be the debit to depreciation expense : On January 1, 2015, XXX Corporation acquired equipment for $260,000. The estimated life of the equipment is 5 years or 40,000 hours. The estimated salvage value is $20,000. If XXX Corporation uses the units of production method of depreciation, what ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd