|
-
Jan 5th, 2001, 03:22 AM
#1
Thread Starter
Addicted Member
Hiyas,
I know how to write an array to a file ...
Code:
Dim NumberOfStrings as Integer
Dim String(2) as String
String(0) = "This"
String(1) = " is"
String(2) = " text!"
NumberOfStrings = 3
Open FileName For Output as #1
Write #1, NumberOfStrings
For a = 1 to NumberOfStrings
Write #1, String(a)
Next a
Close #1
This will produce a file like:
Code:
0
"This"," is"," text!"
How can I write to a file using the same data above, but putting it all on the same line like: (keep in mind I need to use the array, like above)
Code:
0,"This"," is"," text!"
Anyone know?
-Git
-
Jan 5th, 2001, 03:39 AM
#2
New Member
In your for loop, instead of writing them to the file collect them in a temporary string then write the long string. Like the following:
Dim NumberOfStrings as Integer
Dim String(2) as String
dim temp as string
String(0) = "This"
String(1) = " is"
String(2) = " text!"
NumberOfStrings = 3
Open FileName For Output as #1
temp = NumberOfStrings
For a = 1 to NumberOfStrings
temp = temp & String(a)
Next a
Write #1, temp
Close #1
STEngineer
visit stengineer.com for all your Star Trek and LCARS Programming needs
-
Jan 5th, 2001, 03:41 AM
#3
Thread Starter
Addicted Member
-
Jan 5th, 2001, 04:00 AM
#4
PowerPoster
but stengineer sample code will not produce what you mention rite:
Code:
0,"This"," is"," text!"
Where all the double qoute will be missing.
[Edited by Chris on 01-05-2001 at 04:04 AM]
-
Jan 5th, 2001, 04:05 AM
#5
Thread Starter
Addicted Member
It's ok, I changed it slightly and I think it works now...
But... how do I write to a file withought the ""'s around a string?
-Git
-
Jan 5th, 2001, 04:10 AM
#6
PowerPoster
Juz open the file as Append mode
Code:
tmp = Join(Str, Chr(44))
tmp = NumberOfStrings & Chr(44) & tmp
Open Filename For Append As #1
Print #1, tmp
Close #1
Again, you can not name your Array with String 'coz String is the reserve word in VB.
Cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|