[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 130
  • Last Modified:

Using File

I can't write on file.
I want to save my masiv(i,1),masiv(i,2) and masiv(i,3) on file. But I can't
See the source
Thanks


Dim broj As Byte
Dim n As Integer                ' broj redowe w flohdnia file
Dim FileNameIn As String
Dim FileNameOut As String
Dim mas(100, 3) As Double
Dim masiv(100, 3) As Double
FileNameIn = "c:\Testfile1.txt"        ' imeto na whodnia file
FileNameOut = "c:\Testfile11.txt"       ' imeto na izhodnia file

    Open FileNameIn For Input As #1
  n = 0
  While (Not (EOF(1)))
      Line Input #1, x
      n = n + 1
  Wend
    Close #1
   
          Open FileNameIn For Input As #1
  For i = 1 To n
      For j = 1 To 3
          Input #1, mas(i, j)
      Next j
  Next i
Close #1

L1 = 0
For i = 1 To n
L = mas(i, 3)
L3 = mas(1, 3)
L2 = L1 + L
k = (L3 / 2) + (L / 2) + (L2 - L)
A1x = k - (L / 2)
A1y = k + D / 2
L1 = L1 + L
masiv(i, 1) = i
masiv(i, 2) = A1x
masiv(i, 3) = A1y
MsgBox masiv(i, 3)
Next i

  For i = i To n
Open FileNameOut For Output As #1
Print #1, masiv(i, 1), masiv(i, 2), masiv(i, 3)
Close #1
    Next i

0
Nick1_bg
Asked:
Nick1_bg
1 Solution
 
Brendt HessSenior DBACommented:
You're problem is the save code.  You are re-opening and closing the output file at each iteration.  Each time you open it like this, you erase the previous version of the file.

Rewrite your code:


Open FileNameOut For Output As #1
For i = i To n
  Print #1, masiv(i, 1), masiv(i, 2), masiv(i, 3)
Next i
Close #1
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now