Solved

Using File

Posted on 2000-04-18
1
121 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

14 Experts available now in Live!

Get 1:1 Help Now