0% found this document useful (0 votes)
14 views13 pages

Visual Basic Code for Billing Forms

This document contains the code for various forms and functions in a billing software application. It includes coding for a login form, main dashboard form, commercial and domestic bill calculation forms, description form, customer record form, and bill record form. The code handles form loading, button clicks for navigation and data entry/updates, and record filtering, addition, deletion and saving.

Uploaded by

Sohail Choudhary
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views13 pages

Visual Basic Code for Billing Forms

This document contains the code for various forms and functions in a billing software application. It includes coding for a login form, main dashboard form, commercial and domestic bill calculation forms, description form, customer record form, and bill record form. The code handles form loading, button clicks for navigation and data entry/updates, and record filtering, addition, deletion and saving.

Uploaded by

Sohail Choudhary
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

9. CODING: 9.1 Coding of Login Form: Private Sub cmdCancle_Click() End End Sub Private Sub cmdOk_Click() If txtPassword.

Text = "reema" Then [Link] [Link] Else MsgBox "invalid password", vbOKOnly, "alert" [Link] = "" [Link] = "" [Link] End If End Sub 9.2 Coding of MDI Form: Dim RetVal Private Sub MDIForm_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbRightButton Then [Link] mnuEnd End If End Sub Private Sub mnuEndexit_Click() Unload Me End Sub Private Sub mnuExit_Click() End End Sub Private Sub mnuFileCombilFrm_Click() [Link] End Sub Private Sub mnufilecomreport_Click() [Link] End Sub Private Sub mnuFileCusRecfrm_Click() [Link] End Sub Private Sub mnuFileDBillfrm_Click()

[Link] End Sub Private Sub mnuFileDesfrm_Click() [Link] End Sub Private Sub mnufilehomerep_Click() [Link] End Sub Private Sub mnufileopencomercialrec_Click() [Link] End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As [Link]) Select Case [Link] Case Is = "topen" [Link] Case Is = "texit" Unload Me End Select End Sub 9.3 Coding of Commercial Bill Calculation Form Dim u, u1 As Long Dim X, Y, s, d1, d2, d, f As String Private Sub cmdcclear_Click() [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] End Sub Private Sub cmdcexit_Click() End End Sub Private Sub cmdclear_Click() [Link] = "" [Link] = "" [Link] = "" [Link] = ""

[Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" End Sub Private Sub cmdcOk_Click() If [Link] = "" Then MsgBox "please enter unit" [Link] = 0 End If [Link] = "Rs 100.00" f = 100 u = CInt([Link]) If u <= 100 Then X=u*4 [Link] = "Rs " & X [Link] = "Rs " & CStr(u * 0.1) s = u * 0.1 d = (X * 11) / 100 [Link] = "Rs " & d [Link] = "Rs " & (X + s + f + d) ElseIf u > 100 Then X = 100 * 4 d1 = (X * 11) / 100 u1 = u - 100 Y = u1 * 4.25 d2 = (Y * 11.5) / 100 d = d1 + d2 [Link] = "Rs" & (X + Y) s = u * 0.1 [Link] = "Rs" & s [Link] = "Rs" & d End If [Link] = "Rs" & (X + Y + s + d + f) End Sub Private Sub cmdOk_Click() If [Link] = "" Then [Link] = [Link] Else [Link] = "Rs" & (X + Y + s + d + f) - Val([Link]) End If End Sub

Private Sub cmdprevious_Click() [Link] [Link] End Sub Private Sub Form_Load() End Sub 9.3 Coding of Domestic Bill Form: Private Sub cmd1First_Click() [Link] [Link] [Link] = False [Link] = True End Sub Private Sub cmd2Next_Click() [Link] [Link] [Link] = True [Link] = True If ([Link]) = adPosEOF And [Link] = adPosEOF Then MsgBox ("no other record") [Link] [Link] End If End Sub Private Sub cmd3Previous_Click() [Link] [Link] [Link] = True [Link] = True If [Link] = adPosBOF And [Link] = adPosBOF Then MsgBox ("no other record") [Link] [Link] End If End Sub Private Sub cmd4Last_Click() [Link] [Link] [Link] = True

[Link] = False End Sub Private Sub cmdDelete_Click() Dim res As String res = MsgBox("you want to delete the record", vbYesNo + vbQuestion, "alert") If res = vbYes Then [Link] [Link] MsgBox "Record is Deleted" [Link] [Link] Else [Link] [Link] End If End Sub Private Sub cmdlastfive_Click() [Link] = True [Link] = "select top 5 billm,totalbill from cosbdes where=" & Val(txtShopn) '[Link] [Link] End Sub Private Sub cmdNew_Click() [Link] [Link] [Link] End Sub Private Sub cmdSave_Click() Dim res As String res = MsgBox("you want to save the record", vbYesNo + vbQuestion, "alert") If res = vbYes Then [Link] [Link]("shop_no") = [Link]("shop_no") [Link] MsgBox "Record is Updated" [Link] [Link] Else [Link] [Link] [Link] [Link] End If End Sub

Private Sub comerfram_DragDrop(Source As Control, X As Single, Y As Single) End Sub Private Sub Form_Load() [Link] = False End Sub 9.4 Coding of Description Form: Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdOk_Click() If [Link] = 0 Then [Link] = "1.30 Rs" [Link] = "3.00 Rs" [Link] = "3.50 Rs" [Link] = "60.00 Rs" ElseIf [Link] = 1 Then [Link] = "4.00 Rs" [Link] = "4.25 Rs" [Link] = "4.50 Rs" [Link] = "100.00 Rs" End If End Sub Private Sub Form_Load() [Link] ("DOMESTIC 0") [Link] ("COMERCIAL 1") End Sub 9.5 Coding of Domestic Bill Calculation Form: Dim u, u1, u2 As Long Dim X, Y, z, p, d, f As String Private Sub cmd1exit_Click() Unload Me End Sub Private Sub cmdAdd_Click() [Link] [Link] End Sub Private Sub cmdCancle_Click()

[Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" End Sub Private Sub cmdclear_Click() [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] = "" [Link] End Sub Private Sub cmdDelete_Click() Dim res As String res = MsgBox("u w to delete the rec!", vbYesNo, "alert") If res = vbYes Then [Link] MsgBox "record is deleted" [Link] Else [Link] End If End Sub Private Sub cmdExit_Click() [Link] End Sub Private Sub cmdFilter_Click() Dim res res = InputBox("Enter The Criteria", "Filter") [Link] = "select * from Billdec where" & res End Sub Private Sub cmdFind_Click() Dim res As String res = InputBox("enter the criteria for a rec", "find") [Link] res, , adSearchForward, 1

End Sub Private Sub cmdOk_Click() If [Link] = "" Then MsgBox "please enter unit" [Link] = 0 End If [Link] = "Rs 60.00" f = 60 u = CInt([Link]) If u <= 50 Then X = u * 1.3 [Link] = "Rs " & X [Link] = "Rs " & CStr(u * 0.1) p = u * 0.1 d = (X * 14) / 100 [Link] = "Rs " & d [Link] = "Rs " & (X + p + f + d) ElseIf (u > 50 And u <= 300) Then X = 50 * 1.3 u1 = u - 50 Y = u1 * 3 [Link] = "Rs" & (X + Y) p = u * 0.1 [Link] = "Rs" & p If u <= 100 Then d = ((X + Y) * 15) / 100 Else d = ((X + Y) * 23) / 100 End If [Link] = "Rs" & d [Link] = "Rs" & (X + Y + p + d + f) ElseIf u > 300 Then X = 50 * 1.3 Y = 250 * 3 z = (u - 300) * 3.5 [Link] = "Rs" & (X + Y + z) p = CStr(u * 0.1) [Link] = "Rs" & p If u <= 100 Then d = ((X + Y + z) * 15) / 100 Else d = ((X + Y + z) * 23) / 100 End If [Link] = "Rs" & d [Link] = "Rs" & (X + Y + z + p + d + f) End If End Sub

Private Sub cmdoko_Click() If [Link] = "" Then [Link] = [Link] Else [Link] = "Rs" & (X + Y + z + p + d + f) - Val([Link]) End If End Sub Private Sub cmdprevious_Click() [Link] Unload Me End Sub Private Sub cmdSave_Click() Dim res As String res = MsgBox("u w to save the rec", vbYesNo + vbQuestion, "alert") If res = vbYes Then [Link] MsgBox "record is updated" '[Link] Else [Link] [Link] End If End Sub Private Sub Form_Activate() [Link] End Sub Private Sub cmd1First_Click() [Link] [Link] = False [Link] = True End Sub Private Sub cmd2Next_Click() [Link] [Link] = True [Link] = True If ([Link]) = adPosEOF Then MsgBox ("no other record") [Link] End If End Sub Private Sub cmd3Previous_Click() [Link]

[Link] = True [Link] = True If [Link] = adPosBOF Then MsgBox ("no other record") [Link] End If End Sub Private Sub cmd4Last_Click() [Link] [Link] = True [Link] = False End Sub 9.6 Coding of Commercial Bill Record Form: Private Sub cmd1_Click() [Link] [Link] = False [Link] = True [Link] End Sub Private Sub cmd1First_Click() [Link] [Link] = False [Link] = True End Sub Private Sub cmd2_Click() Dim i As Integer If [Link]("cus_id") = [Link]("cus_id") Then [Link] [Link] = True [Link] = True End If If [Link] = adPosEOF Then MsgBox ("no other record") End If [Link] End Sub Private Sub cmd2Next_Click() [Link] [Link] = True [Link] = True If [Link] = adPosEOF Then MsgBox ("no other record") [Link]

End If End Sub Private Sub cmd3_Click() [Link] [Link] = True [Link] = True If [Link] = adPosBOF Then MsgBox ("no other record") [Link] End If End Sub Private Sub cmd3Next_Click() [Link] Unload Me End Sub Private Sub cmd3Previous_Click() [Link] [Link] = True [Link] = True If [Link] = adPosBOF Then MsgBox "no other record" [Link] End If End Sub Private Sub cmd4_Click() [Link] [Link] = True [Link] = False End Sub Private Sub cmd4Last_Click() [Link] [Link] = True [Link] = False End Sub Private Sub cmdDelete_Click() Dim res As String res = MsgBox("you want to delete the record", vbYesNo + vbQuestion, "alert") If res = vbYes Then [Link] [Link] MsgBox "Record is Deleted" [Link] [Link] Else

[Link] [Link] End If End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdfirst_Click() [Link] [Link] = False [Link] = True End Sub Private Sub cmdnext_Click() [Link] [Link] = True [Link] = True If [Link] = adPosEOF Then MsgBox ("no other record") [Link] End If End Sub Private Sub cmdFilter_Click() Dim res As String res = InputBox("Enter The Criteria", "Filter") '[Link]("cus_id") = [Link]("cus_id") [Link] = "select * from bill where" & res '[Link] = "select [Link],[Link] from billdec where" & res End Sub Private Sub cmdlastfive_Click() [Link] = True [Link] = "select top 5 totalbill,billmonth from billdec where cus_id =" & Val(txtcusid) [Link] [Link] End Sub Private Sub cmdNew_Click() [Link] [Link] [Link] End Sub Private Sub cmdPrev_Click()

[Link] Unload Me End Sub Private Sub cmdprevious_Click() [Link] [Link] = True [Link] = True If [Link] = adPosBOF Then MsgBox ("no other record") [Link] End If End Sub Private Sub cmdlast_Click() [Link] [Link] = True [Link] = False End Sub Private Sub cmdSave_Click() Dim res As String res = MsgBox("you want to save the record", vbYesNo + vbQuestion, "alert") If res = vbYes Then [Link] [Link]("cus_id") = [Link]("cus_id") [Link] MsgBox "Record is Updated" [Link] [Link] Else [Link] [Link] [Link] [Link] End If End Sub

Common questions

Powered by AI

User input in the Description Form, via a dropdown list, determines the category—either DOMESTIC or COMMERCIAL—for rates to be applied. Selecting a category updates the displayed rates in text fields corresponding to each rate type (per unit, service, fixed charge). These inputs dynamically adjust the cost calculations across the billing forms by serving as base rates for their respective computations .

For domestic electricity usage between 50 and 300 units, the decision-making logic involves calculating the first 50 units at Rs 1.3 each. Subsequent usage up to 300 units is charged at Rs 3 per unit. A service charge is also calculated at 10% of the total unit used. Depending on whether usage is up to 100 units, different percentages (15% or 23%) are applied on the sum of basic charge and additional charge to calculate duties, which are summed alongside fixed charges to result in the total bill .

The 'cmdOk_Click' method adjusts the total amount due by subtracting any entered bill payment from the calculated total bill for commercial usage. If no payment is entered, it defaults to the full calculated total. This method ensures that the bill reflects any amount already paid, recalculating the outstanding balance accordingly .

Criteria-based operations like filtering and finding records are implemented using input boxes that prompt the user to specify criteria. For filtering, the code constructs SQL-like queries using the input and applies them as record sources for data controls. Finding records involves using the 'Find' method on recordsets, passing the user-specified criteria to locate matching records from current positions within the dataset .

For usage exceeding 100 units, the calculation method involves an initial charge for the first 100 units at Rs 4 per unit, plus an additional charge for any unit above 100 calculated at Rs 4.25 each. Additional elements such as service charges and educational cess are also calculated percentage-wise and added to derive the total amount .

The MDI form enables users to interact with different forms through a series of menu options and a toolbar. These interactions are structured using event-driven subroutines like 'mnuFileCombilFrm_Click' to show the Commercial Bill Form, and similar routines for other forms. The programming uses the 'Show' method to display different forms based on user selection from the menu or toolbar .

The coding differentiates user interactions using event-driven programming, specifically handling events like button clicks. The handlers for these events are defined with subroutines such as 'cmdCancle_Click' and 'cmdOk_Click', where 'cmdOk_Click' checks if the password entered matches a pre-defined string and shows either a message or new form based on this validation .

The coding structure uses message boxes to ensure user confirmation before performing potentially destructive actions like record deletion. For example, prior to deleting a record, a message box is shown with the question 'you want to delete the record' along with 'YesNo' buttons for user input. The record is only deleted if the user confirms with 'Yes' .

Record navigation within the Domestic Bill Form is handled using several commands: 'cmd1First_Click', 'cmd2Next_Click', 'cmd3Previous_Click', and 'cmd4Last_Click'. These commands respectively move the recordset cursor to the first, next, previous, and last record. The code ensures boundaries are handled with error messages by checking the position against the 'adPosEOF' and 'adPosBOF' constants, refreshing the recordsets when necessary .

The system informs the user about incorrect password entry by displaying a message box with the text 'invalid password' and clearing the input fields. This is done within the 'cmdOk_Click' subroutine when the entered password does not match the correct string .

You might also like