[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Working with Files

Posted on 2000-04-30
7
Medium Priority
?
140 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 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

656 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