Solved

Using File

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Concatenate 2 userform comboboxes to a userform text box 4 62
Determine Range to Select 5 48
How to compare ms sql hashbytes results within vb6 5 73
Child Form in front 4 46
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

770 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