Programing Final!

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 20
Reputation: anandarose is an unknown quantity at this point 
Solved Threads: 0
anandarose anandarose is offline Offline
Newbie Poster

Programing Final!

 
0
  #1
Dec 8th, 2006
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, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Programing Final!

 
0
  #2
Dec 9th, 2006
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.
  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!!!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,117
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 282
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: Programing Final!

 
0
  #3
Dec 9th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 20
Reputation: anandarose is an unknown quantity at this point 
Solved Threads: 0
anandarose anandarose is offline Offline
Newbie Poster

Re: Programing Final!

 
0
  #4
Dec 10th, 2006
Originally Posted by WaltP View Post
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 20
Reputation: anandarose is an unknown quantity at this point 
Solved Threads: 0
anandarose anandarose is offline Offline
Newbie Poster

Re: Programing Final!

 
0
  #5
Dec 11th, 2006
Please Help Me!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC