?
Solved

Working with Files

Posted on 2000-04-30
7
Medium Priority
?
139 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
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…
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…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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