Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, July 16, 2011

VB-45 : Calculate Electricity Bill

Design a VB application to calculate the Electricity Bill by taking the Consumer Name,Consumer No, Number of units by taking the details below into consideration.

  • 0 to 100 units      : Rs. 0.50 per unit
  • 101 to 200 units  : Rs. 0.85 per unit
  • 201 to 300 units  : Rs. 1.00 per unit
  • 301 and above    : Rs. 1.25 per unit


A)    Program Design : 

(B) Property(Controls Used) :
  1.  5 Labels with Captions as shown above
  2. 4 Text Boxes and given are their properties : 
  • The Text Property of text boxes for entering Consumer Number,units consumed and total amount should be kept as Zero and the text box for entering consumer name should be kept as blank
  • The Index Property of the four text boxes should be from 0 to 3 respectively
  • The Locked Property of the 4th text box (For calculating total amount) should be kept as True
    3.   One command button with caption Calculate Bill


(C) Attaching Code to the Object :
Private Sub Command1_Click()
Dim sum As Single
Dim unit As Integer

If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "Enter Consumer Number and Name"
End If

unit = Round(Val(Text3.Text))

If unit > 300 Then
sum = (unit - 300) * 1.25
unit = 300
End If

If unit > 200 Then
sum = sum + (unit - 200) * 1
unit = 200
End If

If unit > 100 Then
sum = sum + (unit - 100) * 0.85
unit = 100
End If

sum = sum + unit * 0.5

Text4.Text = sum
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If (Index = 0 Or Index > 1) And (KeyAscii < 48 Or KeyAscii > 57) Then
SendKeys (Char(8))
End If
End Sub

Possible Error  : Sub or Function Not Defined

Refer Electricity Bill also.




If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


====================================================================
===========================================================

1 comment:

Girish said...

Sub or Function Not Defined