| | |
Programing Final!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 20
Reputation:
Solved Threads: 0
Those two words were meant for each other. :cheesy: Anyways, i got the final on Wednesday and it's due next Wednesday.
I have to design a program that takes information from a text document, displays that information, makes calculations based on that information, and then prints those calculations in a separate text document. The document LarryLemon.txt is the record of all cars sold at a used car lot. With each car sold the following variables were recorded in the document: VehiclePrice, LastName$, FirstName$, Phone, Address, City$, State$, ZIP, and Salesperson$.
I have written the following code so far:
The code above only displays the information in the LL.txt file. The three calculations that I need to make are totaling how many cars each sales person sold, the total of their sales, and the average cost of a car he or she sold. Along with the sales persons name, the other two calculations need to be sent to a file for each sales person.
In order to count the total of cars sold by each sales person I was going to use the following code:
The following code will print the three calculations that I mentioned above:
Now the only thing left to do is print, along with the corresponding sales persons name, the total of their sales, and the average cost of a car he or she sold, in a text document. I pretty much have no idea how to do that. So, if anyone here could give me some insight into this it would be greatly appreciated.
Also, i have no idea if any of the code past the first snip-it works because my PC is in the shop. If someone would run them and let me know which ones work and which ones don't, that too would be greatly appreciated.
Thanks,
Ananda
I have to design a program that takes information from a text document, displays that information, makes calculations based on that information, and then prints those calculations in a separate text document. The document LarryLemon.txt is the record of all cars sold at a used car lot. With each car sold the following variables were recorded in the document: VehiclePrice, LastName$, FirstName$, Phone, Address, City$, State$, ZIP, and Salesperson$.
I have written the following code so far:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'Ananda Bennett '12/06/06 'Sales program OPEN "c:\LarryLemon.txt" FOR INPUT AS #1 DO WHILE EOF(#1) <> -1 INPUT #1, VehiclePrice, LastName$, FirstName$, Phone, Address, City$, State$, ZIP, Salesperson$ PRINT "VehiclePrice LastName FirstName Phone Address City State ZIP Salesperson" PRINT "................................................................................................" PRINT VehiclePrice; " " ;LastName$; " " ;FirstName$; " " ;Phone; " " ;Address; " " ;City$; " " ;State$; " " ;ZIP; " " ;Salesperson$ PRINT " " LOOP CLOSE #1
In order to count the total of cars sold by each sales person I was going to use the following code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'i will do this for each sales person IF Salesperson = Taylor THEN LET count = count + 1
The following code will print the three calculations that I mentioned above:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
LET totalcost = cost + cost LET avgcost =(totalcost)/count PRINT " Vehicles sold: ";count PRINT " Total sales: ";totalcost PRINT" Average sales: ";avgcost
Now the only thing left to do is print, along with the corresponding sales persons name, the total of their sales, and the average cost of a car he or she sold, in a text document. I pretty much have no idea how to do that. So, if anyone here could give me some insight into this it would be greatly appreciated.
Also, i have no idea if any of the code past the first snip-it works because my PC is in the shop. If someone would run them and let me know which ones work and which ones don't, that too would be greatly appreciated.
Thanks,
Ananda
Hi,
I'am giving u the most simplest way of doing this.
Place 1 ListBox on the Form say lstSMan
Check Property, Sorted = False
Clear lstSMan.
Assuming U have Opened the File and u r in a loop.
u have populated the variable SalesPerson.
write this code inside the loop.
I hope it is clear. if u have problems, let me know.
Regards
Veena
I'am giving u the most simplest way of doing this.
Place 1 ListBox on the Form say lstSMan
Check Property, Sorted = False
Clear lstSMan.
Assuming U have Opened the File and u r in a loop.
u have populated the variable SalesPerson.
write this code inside the loop.
vb Syntax (Toggle Plain Text)
lstSMan.Clear 'Open file 'Do lstSMan.Text = SalesPerson If lstSMan.SelCount = 0 Then lstSMan.AddItem SalesPerson lstSMan.ItemData(lstSMan.NewIndex) = 0 lstSMan.Selected(lstSMan.NewIndex) = True End If lstSMan.ItemData(lstSMan.ListIndex) =lstSMan.ItemData(lstSMan.ListIndex) +1 'Write Loop Condition 'Do Any Other Coding here So as per the above code, after the loop, lstSMan Consists of All the SalesPersons and their corresponding Counter is in their ItemData Property, use this code to print. Dim i As Integer For i = 0 To lstSMan.ListCount-1 Debug.Print lstSMan.List(i) & " " & lstSMan.ItemData(i) Next
I hope it is clear. if u have problems, let me know.
Regards
Veena
Last edited by WaltP; Dec 9th, 2006 at 4:15 am. Reason: Code Tags!!!
QVeen72, you've been asked multiple times to use code tags. Is there a problem with understanding what they are? How to use them? Where to get the information? All this has been mentioned... Check the post at the top if the forum labled Please use BB Code and Inlinecode tags
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Oct 2006
Posts: 20
Reputation:
Solved Threads: 0
•
•
•
•
QVeen72, you've been asked multiple times to use code tags. Is there a problem with understanding what they are? How to use them? Where to get the information? All this has been mentioned... Check the post at the top if the forum labled Please use BB Code and Inlinecode tags
Thanks again,
Ananda
![]() |
Similar Threads
- Final Year Project (Computer Science)
- Wanted help on final year project (Geeks' Lounge)
- Wanted help for a Final Year Project Theme (Computer Science)
- Final System Picked - Compatible? (Troubleshooting Dead Machines)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Midi in VB 5.0
- Next Thread: haw i can know a duration for this video
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






