Results 1 to 3 of 3

Thread: [RESOLVED] generate text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    5

    Resolved [RESOLVED] generate text file

    how to generate text file from the range that i define. can anybody gave me the code,pls
    x= 2.9 to 2.95
    y=101.75 to 101.8

    in the text file,it arrange like this
    x y
    2.90 101.75
    2.91 101.76


    it's that any problem with this code? i hav try this code but does not work.

    Code:
    Dim x As Single
    Dim y As Single
    
    
    Open "D:\data.txt" For Output As #1
    
    
    For x = 2.9 To 2.95
        For y = 101.75 To 101.8
                y = y + 0.0001
                y = y
        Print #1, x & " " & y & ";" & "60"
        Next y
    x = x + 0.0001
    x = x
    Next x
    thanks...

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: generate text file

    In your example you're incrementing both at the same time. In your code you're incrementing y for each value of x. Which way do you want to do it?

    If the code is correct, try this
    Code:
    Dim x As Single
    Dim y As Single
    
      Open "D:\data.txt" For Output As #1
      For x = 2.9 To 2.95 Step 0.01
        For y = 101.75 To 101.8 Step 0.01
          Print #1, Format$(x, "#.00") & " " & Format$(y, "###.##") '& ";" & "60" no idea what this is for
        Next y
      Next x
      Close #1
    It produces
    Code:
    2.90 101.75
    2.90 101.76
    2.90 101.77
    2.90 101.78
    2.90 101.79
    2.91 101.75
    2.91 101.76
    2.91 101.77
    2.91 101.78
    2.91 101.79
    2.92 101.75
    etc.
    Last edited by Al42; May 1st, 2007 at 09:33 AM.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    5

    Re: generate text file

    tahnks Al42..

    your code is work well

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