Solved

Working with Files

Posted on 2000-04-30
7
137 Views
Last Modified: 2010-05-18
I have a array and want to save it in file but without space between each field.
See my source.
Open TochkiOut For Output As #1
    For i = 1 To n
Print #1, masiv(i, 1), ",", masiv(i, 2), ",", masiv(i, 3), ",", masiv(i, 4), ",", masiv(i, 5), ",", masiv(i, 6), ",", masiv(i, 7), ",", masiv(i, 8), ",", masiv(i, 9)
    Next i
Close #1

I want to have this kind of orientation ot text.
1,100,100,100 .........
Without space between arrays.
Thanks
0
Comment
Question by:Nick1_bg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Accepted Solution

by:
Vbmaster earned 50 total points
ID: 2763852
You can use & instead of ',' between the elements like this..

Print #1, masiv(i, 1) & "," & ...
0
 

Expert Comment

by:flench
ID: 2763853
Put in place of a "," character, a ";" between the arrays values.

Example :

Print #1, masiv(i, 1); ","; masiv(i, 2); ","; masiv(i, 3); ","; masiv(i, 4); ","; masiv(i, 5); ","; masiv(i, 6); ","; masiv(i, 7); ","; masiv(i, 8); ","; masiv(i, 9)

You can also convert the arrays numbers into string, and then use the "Format" function to print the correct value.

Example : Format(<string)

   
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2763867
Concatenating the array element with the '&' character is better than using the approach recommended by flench because '&' will create one 'large' string in memory and then save this string to disk 'at once', instead of having to communicate with the disk for every element a'la using ';'. Harddisk access is slow - memory is fast(er).
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 14

Expert Comment

by:wsh2
ID: 2765249
It sounds like you just want a standard CSV file which is very portable from application to application. To do this simply, you want to use the Write # statement, rather than the Print #. The Write # will automatically add commas and place double quotes around string Text if it is present. To write your whole table would then look like this..

Open TochkiOut For Output As #1
For x = 1 To xLimit
   Write #1, _
       masiv(x,1), _
       masiv(x,2), _
       masiv(x,3), _
       masiv(x,4), _
       masiv(x,5), _
       masiv(x,6), _
       masiv(x,7), _
       masiv(x,8), _
       masiv(x,9)
Next x
Close #1

To Read it back in use:

Open TochkiOut For Input As #1
For x = 1 To xLimit
   Input #1, _
       masiv(x,1), _
       masiv(x,2), _
       masiv(x,3), _
       masiv(x,4), _
       masiv(x,5), _
       masiv(x,6), _
       masiv(x,7), _
       masiv(x,8), _
       masiv(x,9)
Next x
Close #1

This will give you a CSV file that is portable from apllication to application. One cautionary note though, if you are writing strings that have a double quote in them.. ie Chr(34).. you want to first double them up inside the string (ie "" -or- chr(34)chr(34)) before writing, so that they are read and processed properly.

0
 
LVL 1

Author Comment

by:Nick1_bg
ID: 2765614
I will accept the answer of VBMASTER
0
 
LVL 1

Author Comment

by:Nick1_bg
ID: 2765617
Thansk VBMASTER :-))
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2765891
Glad I could help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

736 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