Answer to Question #8765 in Visual Basic for wilfred

Question #8765
piece of equipment half-day full-day
1.rug cleaner R 16.00 R 24.00
2.lawn mower R 12.00 R 18.00
3.paint sprayer R 20.00 R 30.00

the table gives the price schedule for edddie's equipment rental.full day rentals cost one and a half-times half day rentals.write va program that display the table in a list box when a appropriate button is clicked on display a bill in another listbox based on the item number and time period chosen by a customer.the bill should include a R30.00 deposit.A simple i wil send to you now
1
Expert's answer
2012-04-28T09:48:35-0400
VERSION 5.00
Begin VB.Form Form1
Caption = quot;Form1"
ClientHeight = 3840
ClientLeft = 60
ClientTop = 450
ClientWidth & = 8655
LinkTopic = quot;Form1"
ScaleHeight & = 3840
ScaleWidth = 8655
StartUpPosition = 3& 'Windows Default
Begin VB.CommandButton Command10
Caption = quot;Remove"
Height = 495
Left = 3840
TabIndex & = 15
Top = 2160
Width & = 1095
End
Begin VB.CommandButton Command9
Caption = quot;Remove"
Height = 495
Left = 3840
TabIndex & = 14
Top = 1560
Width & = 1095
End
Begin VB.CommandButton Command8
Caption = quot;Remove"
Height = 495
Left = 3840
TabIndex & = 13
Top = 840
Width & = 1095
End
Begin VB.CommandButton Command7
Caption = quot;Remove all"
Height = 975
Left = 120
TabIndex & = 12
Top = 2760
Width & = 4815
End
Begin VB.CommandButton Command6
Caption = quot;R 30.00 "
Height = 495
Left = 2640
TabIndex & = 11
Top = 2160
Width & = 1095
End
Begin VB.CommandButton Command5
Caption = quot;R 20.00 "
Height = 495
Left = 1440
TabIndex & = 10
Top = 2160
Width & = 1095
End
Begin VB.CommandButton Command4
Caption = quot;R 18.00 "
Height = 495
Left = 2640
TabIndex & = 9
Top = 1560
Width & = 1095
End
Begin VB.CommandButton Command3
Caption = quot;R 12.00 "
Height = 495
Left = 1440
TabIndex & = 8
Top = 1560
Width & = 1095
End
Begin VB.CommandButton Command2
Caption = quot;R 24.00 "
Height = 495
Left = 2640
TabIndex & = 5
Top = 840
Width & = 1095
End
Begin VB.CommandButton Command1
Caption = quot;R 16.00 "
Height = 495
Left = 1440
TabIndex & = 4
Top = 840
Width & = 1095
End
Begin VB.ListBox List1
Enabled = 0 #039;False
Height = 3570
ItemData & = quot;8765.frx":0000
Left = 5040
List = quot;8765.frx":0007
TabIndex & = 0
Top = 120
Width & = 3495
End
Begin VB.Label Label5
Alignment = 2& 'Center
Caption = quot;Full-day"
Height = 375
Left = 2640
TabIndex & = 7
Top = 360
Width & = 1095
End
Begin VB.Label Label4
Alignment = 2& 'Center
Caption = quot;Half-day"
Height = 375
Left = 1440
TabIndex & = 6
Top = 360
Width & = 1095
End
Begin VB.Label Label3
Caption = quot;Paint sprayer"
Height = 495
Left = 120
TabIndex & = 3
Top = 2280
Width & = 1215
End
Begin VB.Label Label2
Caption = quot;Lawn mower"
Height = 615
Left = 120
TabIndex & = 2
Top = 1560
Width & = 1095
End
Begin VB.Label Label1
Caption = quot;Rug cleaner"
Height = 495
Left = 120
TabIndex & = 1
Top = 840
Width & = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bill(3) As Integer 'array holding all fees to calculate
Dim total As Integer ' total sum of fees

Sub item_process() 'subprocedure to calculate fees and output them into listbox
total = bill(0) + bill(1) + bill(2) + bill(3)
List1.Clear
If total = 30 Then Exit Sub
List1.AddItem ("BILL")
List1.AddItem ("=====")
If bill(0) > 0 Then List1.AddItem ("Rug cleaner: R " & bill(0) & ".00")
If bill(1) > 0 Then List1.AddItem ("Lawn mower: R " & bill(1) & ".00")
If bill(2) > 0 Then List1.AddItem ("Paint sprayer: R " & bill(2) & ".00")
If bill(3) > 0 Then List1.AddItem ("Deposit: R " & bill(3) & ".00")
List1.AddItem ("=====")
List1.AddItem ("TOTAL: R " & total & ".00")
End Sub

'Each button click changes fees array and calls item_process sub
Private Sub Command1_Click()
bill(0) = 16
item_process
End Sub
Private Sub Command2_Click()
bill(0) = 24
item_process
End Sub
Private Sub Command3_Click()
bill(1) = 12
item_process
End Sub
Private Sub Command4_Click()
bill(1) = 18
item_process
End Sub
Private Sub Command5_Click()
bill(2) = 20
item_process
End Sub
Private Sub Command6_Click()
bill(2) = 30
item_process
End Sub

'buttons to remove items. when array item=0, it is not displayed
Private Sub Command8_Click()
bill(0) = 0
item_process
End Sub
Private Sub Command9_Click()
bill(1) = 0
item_process
End Sub
Private Sub Command10_Click()
bill(2) = 0
item_process
End Sub

'Button to remove all items
Private Sub Command7_Click()
List1.Clear
bill(0) = 0
bill(1) = 0
bill(2) = 0
End Sub

'on load we assign R 30 deposit.
Private Sub Form_Load()
List1.Clear
bill(3) = 30
End Sub

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS