- Home
·
- Miscellaneous
·
- Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa
Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa
Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sales price and dealer cost of a car
Rate Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa
(2(2 Vote))
Private Sub Command1_Click()
Call OpenFile
End Sub
Private Sub OpenFile()
Dim fileName As String
Dim fntitle As String
Dim fnprompt As String
fntitle = "Name of File"
fnprompt = "Enter path for data text file."
fileName = InputBox(fnprompt, fntitle)
Open fileName For Input As #1
Picture1.Print "File loaded successfully."
End Sub
Private Sub Command2_Click()
Dim SalesName As String
Dim FinalPrice As Single, DealerCost As Single
Dim Done As Boolean
Dim SalesCost As Single
Dim Commission As Single
Dim NewSalesCost As Single
Dim TotalCommission As Single
Do While Not EOF(1)
Call GetName(SalesName)
Call InitializeSalesInfoAndDone(FinalPrice, DealerCost)
Done = False
Do While Not Done
Call GetSaleAndCost(SalesCost, NewSalesCost)
If FinalPrice = 0 And DealerCost = 0 Then
Done = True
Else
Call CalcSales(Commission, TotalCommission)
End If
Loop
Call PrintSalesPersonInfo
Loop
Call PrintTotalInfo
Call CloseFile
End Sub
Private Sub GetName(SalesName As String)
Input #1, SalesName
End Sub
Private Sub InitializeSalesInfoAndDone(FinalPrice As Single, DealerCost As Single)
Input #1, FinalPrice, DealerCost
End Sub
Private Sub GetSaleAndCost(SalesCost As Single, NewSalesCost As Single)
SalesCost = Val(FinalPrice) - Val(DealerCost)
NewSalesCost = SalesCost + NewSalesCost
End Sub
Private Sub CalcSales(Commission As Single, TotalCommission As Single)
Commission = NewSalesCost * 0.15
TotalCommission = NewSalesCost + TotalCommission
End Sub
Private Sub PrintSalesPersonInfo()
Picture1.Print SalesName, Commission
End Sub
Private Sub PrintTotalInfo()
Picture1.Print "The Total Commission is: "; TotalCommission
End Sub
Private Sub CloseFile()
Close #1
End Sub
Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa Comments
No comments yet — be the first to post one!
Post a Comment