visual Basic 2010 help Calculations Help

hey guys i am having issues with calculations on visual basic 2010

i know i am on the easy part right now but i am having hard time getting the hang of it.
ill post of pictures of what i need to do.

**2. The application provides one simple output – the amount of electricity bill.
3. Use the following calculation rules
a. Electricity rate is 10 cents per unit of electricity
b. Consumer is only charged for the net electricity consumed (i.e if the electricity consumed is 500 units and electricity produced is 50 units then the consumer will only be charged for 500 – 50 = 450 units of electricity
c. Consumer gets a credit of $5.65 for each Energy Star appliance in the household.
4. Illustrated Example:
a. If units of Electricity Consumed = 1000, and
b. Number of Energy Star appliances = 3, and
c. Units of electricity generated = 200, then
d. Electricity Bill Amount = ((1000 – 200) * 0.10) – (3*5.65) = $63.05
5. Helpful hints
a. Liberal use of comments/remarks are encouraged
b. Use variables for storing all the important data items
c. Submit your application in a J-Drive folder marked “Homework 1”
d. You will be able to work on this homework in the Thu’s lab class
e. The application should be able to take in all the relevant inputs and should have buttons for calculating the bill amount, clearing all the input fields and closing the form.
**

Re: visual Basic 2010 help Calculations Help

Hey Usman Bro this sounds like your first programming class assignment, i dont work on basic or visual basic, and i never even tried to do anything on visual basic, i was all a C/C++/C# guy, anyways the logic is same in any programming language, its just the keywords and the way you write in is different. So i will give you the program logic, you can convert it into visual basic,

First declare all your variables.

  1. Unit of Electricity used - Unit_Used
  2. Number of Energy Star Appliances - Num_EnergyStar
  3. Unit of Electricity Produced from Solar Cells - Unit_Produced
  4. Total Bill - Total

Now get the data from the text fields and store into the variables you just declared, the text fields takes string data type, so you need to explicitly convert them to numbers before storing.

Then on your calculate button click event

Total = ((Unit_Used - Unit_Produced) * 0.10) - (Num_EnergyStar * 5.65)

Display this Total on the label, now you have to convert from number to string data type.

For Clear Button Click event

Make all your variables equal to zero, or empty in the case of Text Fields

For the close button click event

this.exit();

Done, If you want i can write the program in C#, and then you can convert it into Visual Basic automatically, but its better to try yourself.

P.S: for all the code ninjas and code warriors, am not a programmer by profession.

Re: visual Basic 2010 help Calculations Help

thank Rayan for your help, figured it out. dumb me typing it wrong. yea it's my first programming class. Thanks for your help though.

Re: visual Basic 2010 help Calculations Help

Its a one line code application . I'll suggest that grab a visual basic book and read couple of chapters before starting your first app. There are also a lot of video tutorials online that you can watch.

Btw before you do your calculations you might want to convert text fields to double or int i.e. Double.TryParse(txtfield.text, value)

Good luck