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

  How to make game in pascal programming lanuage

How to make game in pascal programming lanuage

  Accepts two int arguments and returns their sum

Assume the availability of a class named Arithmetic that provides a static method , add , that accepts two int arguments and returns their sum .

  Accuracy and completeness of computations

Analysis right and you have to develop a plausible argument to "prove" that your analysis is correct

  Program for a computer dating service

Write a program for a computer dating service. Each client gives you his or her name, phone number, and a list of interests.

  Write the psuedocode showing the logic for a program

Write the psuedocode showing the logic for a program that allows a user to enter 12 numbers and then displays them in the reverse order of their entry

  Write an assembly code segment that calls the subroutine

Write an assembly code segment that calls the subroutine New Functionif bits 5 and 6 of PORTD equal 1 and write the same code segment in part (a) using structured assembly constructs.

  Give hypertext link of the internet location of program

Describe in one or two paragraphs what you observe. Give hypertext link of the internet location of the program (or applet) you found.

  Write down a program which explores the seating patterns

write a program that explores the seating patterns related to course performance by using an array of student scores.

  Design bank account class with data members-member functions

Design the Bank Account class with suitable data members and member functions - think of attributes or features of a bank account - think of kind of data (and actions) you require to open account.

  Examine a desktop application

Examine a desktop application. How would you make it mobile. Examine a mobile application. Why is it not a desktop application

  Use of various bash commands

Assignment On: This work will require scripting the use of various bash commands and / or small programs that involve directory and file structures.

  Design and write a program

Design and write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.

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