943,962 Members | Top Members by Rank

Ad:
Dec 8th, 2006
0

Programing Final!

Expand Post »
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:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'Ananda Bennett
  2. '12/06/06
  3. 'Sales program
  4.  
  5. OPEN "c:\LarryLemon.txt" FOR INPUT AS #1
  6.  
  7. DO WHILE EOF(#1) <> -1
  8. INPUT #1, VehiclePrice, LastName$, FirstName$, Phone, Address, City$, State$, ZIP, Salesperson$
  9.  
  10. PRINT "VehiclePrice LastName FirstName Phone Address City State ZIP Salesperson"
  11. PRINT "................................................................................................"
  12. PRINT VehiclePrice; " " ;LastName$; " " ;FirstName$; " " ;Phone; " " ;Address; " " ;City$; " " ;State$; " " ;ZIP; " " ;Salesperson$
  13. PRINT " "
  14.  
  15. LOOP
  16.  
  17. CLOSE #1
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 'i will do this for each sales person
  2. IF Salesperson = Taylor THEN
  3. 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)
  1. LET totalcost = cost + cost
  2. LET avgcost =(totalcost)/count
  3. PRINT " Vehicles sold: ";count
  4. PRINT " Total sales: ";totalcost
  5. 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
Attached Files
File Type: txt LarryLemon.txt (15.8 KB, 7 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anandarose is offline Offline
20 posts
since Oct 2006
Dec 9th, 2006
0

Re: Programing Final!

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.
vb Syntax (Toggle Plain Text)
  1. lstSMan.Clear
  2. 'Open file
  3. 'Do
  4. lstSMan.Text = SalesPerson
  5. If lstSMan.SelCount = 0 Then
  6. lstSMan.AddItem SalesPerson
  7. lstSMan.ItemData(lstSMan.NewIndex) = 0
  8. lstSMan.Selected(lstSMan.NewIndex) = True
  9. End If
  10. lstSMan.ItemData(lstSMan.ListIndex) =lstSMan.ItemData(lstSMan.ListIndex) +1
  11.  
  12. 'Write Loop Condition
  13. 'Do Any Other Coding here
  14.  
  15. 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.
  16.  
  17. Dim i As Integer
  18. For i = 0 To lstSMan.ListCount-1
  19. Debug.Print lstSMan.List(i) & " " & lstSMan.ItemData(i)
  20. 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!!!
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Dec 9th, 2006
0

Re: Programing Final!

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
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is online now Online
7,744 posts
since May 2006
Dec 10th, 2006
0

Re: Programing Final!

Click to Expand / Collapse  Quote originally posted by WaltP ...
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
Thank you for posting that. I'm new to programing so when I read QueenV's response I thought either there was something wrong with me or i just wasn't geek enough yet to understand it. :p

Thanks again,

Ananda
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anandarose is offline Offline
20 posts
since Oct 2006
Dec 11th, 2006
0

Re: Programing Final!

Please Help Me!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anandarose is offline Offline
20 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Midi in VB 5.0
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: haw i can know a duration for this video





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC