basic to input consumer number, consumer name,area urban,ruraly,month of billing,last reading,current reading andcalculate thebill amount


Draw flowchart, write an algorithm and programin visual basic to input consumer number, consumer name, area (urban,ruraly, month of billing, last reading, current reading and calculate the bill amount according to the following conditions.
Household:
1 to 30 - 1.00Rs.
31 to 100 - 2.55Rs.
101 to 300 - 2.95Rs.
301 onwards - 4.55Rs.
Industrial:
1 to 1000 - 2.40Rs.
1001 to 1500 - 3.00Rs.
1501 onwards - 3.40Rs.
Non Household:
1 to 100 - 2.56RS.
101 to 200 - 4.10Rs.
201 onwards - 5.00Rs.
Urban water supply - 2.25 Rs.
Rural, water supply - 1.40 Rs .
Agriculture - 0.90Rs.
Rural Lighting - 1.70Rs.
Urban Lighting - 2.50Rs.
Poultry Farm - 0.90Rs.
Total Reading = Current Reading - Last Reading

Ans:


Dim c, r1, a, b, p As Integer


Private Sub Form_Load()

cboOptions.Addltem "HOUSEHOLD", 0
cboOptions. Addltem "NONHOUSEHOLD",1
cboOptions.Addltem " IDNUSTRIAL", 2
cboOptions.Addltem "URBAN WTAER SUPPLY", 3
cboOptions. Addltem "RURAL WATER SUPPLY", 4
cboOptions.Addltem "AGRICULTURE", 5
cboOptions.Addltem "RURAL LIGHTING", 6
cboOptions.Addltem "URBAN LIGHTING", 7
cboOptions.Addltem "POULTRY FARM", 8

End Sub


Private Sub cmdCalculate_Click ()
p2 = 0

t1 = cboOptions.Text
c = Clnt(txtCMR.Text) - CInt (txtLMR. Text)
If t1 = "HOUSEHOLD" Then for Household purpose
If c > 300 Then
r1 = c - 300
p = rl * 4.55
p2 = p + 798.5

End If


If c > 100 And c <= 300 Then
r1 = c - 100
p = r1 * 2.95
p2 = p + 208.5

End If
If c > 30 And c <= 100 Then
r1 = c - 30
p = r1 * 2.55
p2 = p + 30

End If
If c <= 30 Then
r1 = c - 0
p = r1 * 1
p2 = p

End If
Elself t1 = "NONHOUSEHOLD" Then for non household
If c > 200 Then

r1 = c - 200
p= r1 * 5
p2 = p + 660
End If
If c > 100 And c <= 200 Then
r1 = c - 100
p = r1 * 4.1
p2 = p + 250
End If
If c <= 100 Then
r1 = c - 0
p = r1 * 2.5
p2 = p
End If
Elself t1 = "IDNUSTRIAL" Then for Industrial
If c > 15000 Then

r1 = c - 15000
p = r1 * 3.4

p2 = p + 44400
End If
If c > 1000 And c <= 15000 Then

r1 = c - 1000
p = r1 * 3
p2 = p + 2400
End If
If c <= 1000 Then

r1 = c - 0
p = r1 * 2.4
p2 = p
End If
Elself t1 = "URBAN WTABR SUPPLY" Then
p2 = c * 2.25
Elself t1 = "RURAL WATER SUPPLY" Then
p2 = c * 1.4

Elself t1 = "AGRICULTURE" Then
p2 = c * 0.9
Elself t1 = "RURAL LIGHTING" Then

p2 = c * 1.7
Elself t1 = "URBAN LIGHTING" Then

p2 = c * 2.5
Else
p2 = c * 0.9
End If

txtTAmt.Text = CStr(p2)

End Sub

Private Sub cmdClear_Click()
txtName.Text = Clear
txtNumber.Text = Clear

txtMOB.Text = Clear
txtLMR.Text = Clear
txtCMR.Text = Clear
cboOptions. Text = Clear

End Sub
Private Sub cmdExit_Click()
Unload Me

End Sub

No comments:

Visual Basic-6 has emerged as one of the standard Windows Programming Language and it has become a must for all Software people for developing Applications in Visual Environment. So it is, one must learn Visual Basic-6.

What is our Objective in this Courseware?


The Overall Objective in this Courseware is to give a Hands-on Approach to develop different projects in Visual Basic-6.0 using intrinsic, professional and user–created ActiveX controls and also develop projects using databases, DAO’s, ADO’s, DLL’s, Documents, Crystal Reports etc. covering almost all the essential features of VB-6 Professional Edition. After reading one lesson any interested reader will be able to get complete hands-on experience with the VB project and get a sense of fulfilment and achievement. Learning by doing is the motto with which this courseware is written. After giving a short introduction about VB-6 we will explain how to create and execute a project in VB using some intrinsic ActiveX controls. Creating and executing projects will be the central theme of all the lessons which we will be giving in this courseware.

What is Visual Basic-6?


Visual Basic-6 has its origin in Basic which was developed round about the year 1960, when high level languages were just being introduced to the computer community. Microsoft has made it extremely powerful by gearing all its good features to the Windows environment. Starting with the version 3 and then with 4, and then with 6, Visual Basic is now at version 6. Basic is a Procedure Oriented Language intended to implement single tasks in text based environment whereas Visual Basic is an Event Driven Language intended to implement Projects or Applications containing multiple tasks in Windows Environment.

What can Visual Basic do for you?

Visual Basic can serve as an ideal front end tool for the clients to interact. It has got connectivity mechanisms for all types of databases situated far and wide in a network and so it can cater to the needs of a large body of clients. Using the latest ActiveX technologies, it can integrate the functionalities provided by other applications like Word Excel and other Windows. Its internet capabilities provide easy access to documents and applications across the internet. Above all it embodies the Object Oriented Technology, which is the cutting edge technology for all the present day developments in the Software World. The final application is a true EXE file and so can be freely distributed.


Structure of VB-6 Projects:


We said earlier that VB-6 implements projects or applications. A project is developed using one or more Forms. A Form is simply a window containing one or more Controls. Controls in VB consist of labels, text boxes, list boxes, combo boxes, scroll bars etc. which are the constituents of windows environment. It is only the controls that give VB, its immense power and so there is a lot of interest in creating more and more powerful controls. ActiveX controls mark a significant development in controls technology. In fact all controls in VB-6 are ActiveX controls, which have the extension .ocx. These controls have properties whose values can be initialized at design time and also varied during run time. The properties are something like variables. The controls are activated by codes written in a high level language. By associating our problem variables with the properties of the controls, our problem variables can be manipulated to give the problem solution. In summary we can say that a VB project is made of forms, controls and their properties and codes.

Integrated Development Environment:

The working environment in VB is often referred to as the Integrated Development Environment or IDE, because it integrates many different functions such as design, editing, compiling and debugging within a common environment. Since all our projects are developed only in the IDE, let us now have a brief look at its features. You will be able to understand their uses at the time of building projects. The VB IDE looks as shown in the figure.