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

  What programming language did grace hopper invent

What programming language did Grace Hopper invent. What was the name of the network begun in 1969? What does it stand for

  Extend the user management

Extend the user management so that user can be stored in database - user can be administrator and he can access that admin page

  Write lisp function to reverse order of the elements in list

Write a Lisp function that: given a two-element list, reverse the order of the elements in the list (cannot use the LISP reverse function).

  Identify at least two advantages to using oop

Use the Internet to research the advantages, features, and common examples of OOP and EDP. Note: You may use the Association for Computing Machinery (ACM) Digital Library to support research on the above topics.

  What is a data flow diagram

Define what is meant by a process in a process model. How should a process be named? What information about a process should be stored in the CASE repository?

  Provide a graphical view of the planets and bases

Intergalactic Navigation. Provide a graphical view of the planets and bases, and meteorite fields and display the requested path from start to destination.

  Write program that would estimate magnitude

Write a program that would estimate the magnitude (liters/day) and cost of the water saved based on the community's population.

  Program-dynamically check store-s inventory-central office

You are the outside consultant to large chain of grocery stores. Store's management would like to dynamically check store's inventory from central office.

  Write pseudocode for procedure construct-optimal-bst

Write pseudocode for procedure Construct-Optimal-BST (root) which, table root, outputs structure of the optimal bimary search tree.

  How long will it take the program to run

How long will it take the program to run with 1000 processors, if each processor is as fast as the single processor on which the serial program was run?

  Which of the following is not included in a pseudocode

Which of the following is not included in a pseudocode program?

  Write program which will accept list of student-s name

Write a program which will accepts list of student's name, individual scores for quiz1, quiz2 and quiz3. Your program must then compute for average of 3 quizzes.

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