Solved

Using File

Posted on 2000-04-18
1
122 Views
Last Modified: 2012-05-04
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
Comment
Question by:Nick1_bg
1 Comment
 
LVL 32

Accepted Solution

by:
bhess1 earned 50 total points
ID: 2728640
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now