VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa

by anonymous (267 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 29th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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



Download this snippet    Add to My Saved Code

Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa Comments

No comments have been posted about Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa. Why not be the first to post a comment about Using a data text file containing a name of a salesperson, a pair of numbers declaring the final sa.

Post your comment

Subject:
Message:
0/1000 characters