Results 1 to 5 of 5

Thread: Csv *Resolved*

  1. #1

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372

    Csv *Resolved*

    Hey guys, need a little help here. I'm writing a small prog that reads a text file and outputs the necessary data to a csv file. I got it to sort of work:

    VB Code:
    1. Dim NumberofTemps As Integer
    2. Dim TempDate As String
    3. Dim Temperature As Integer
    4. Dim TempNumber As Integer
    5. Open cdlFiles.FileName For Input As #1
    6. Open App.Path + "\temp.csv" For Output As #2
    7. Input #1, NumberofTemps
    8. For TempNumber = 1 To NumberofTemps
    9.     Input #1, TempDate, Temperature
    10.     Write #2, TempNumber, Temperature
    11. Next TempNumber
    12. Close 1
    13. Close 2

    Each text file can have up to 31 lines like the following:
    01/08/02 HighTemp = ,19
    It then outputs to the csv file:
    1,19

    But I can only get it to do the first line.
    Last edited by GingerNut; Nov 4th, 2002 at 09:40 AM.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  2. #2
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    can you post a sample file?
    it doesnt look that hard to do

    is NumberofTemps greater than 1?

  3. #3
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Just after:
    Input #1, NumberofTemps

    Put a:
    MsgBox "Loops: " & NumberofTemps

    and tell us what it says.

    It could well be that you need to manipulate NumberOfTemps (make sure its a valid integer value) between reading it and using it in your loop.

  4. #4

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    It says "Loops: 1"
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  5. #5

    Thread Starter
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    It's ok, I got it sorted. I changed to this:
    VB Code:
    1. Dim NumberofTemps As Integer
    2. Dim TempDate As String
    3. Dim Temperature As Integer
    4. Dim TempNumber As Integer
    5. Open cdlFiles.FileName For Input As #1
    6. Open App.Path + "\temp.csv" For Output As #2
    7. TempNumber = 1
    8. Do Until EOF(1)
    9.     Input #1, TempDate, Temperature
    10.     Write #2, TempNumber, Temperature
    11.     TempNumber = TempNumber + 1
    12. Loop
    13. Close 1
    14. Close 2
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width