|
-
May 7th, 2001, 08:02 PM
#1
Variant Array to single line Text file
I have an array with a variable number of elements and i'm trying to read it into a text file with all the elements on the same line ! ...
I'm able to put the array elements in a text file one line at a time using the following:
Open App.Path & "\test.txt" For Output As #1
Dim v As Variant
For Each v In input1
Print #1, v
Next
Close #1
Where code above this has already read in the values for the Input1() array from an input grid.
Does someone know how to write it all on the same line ??
Thanks,
Shannon.
-
May 7th, 2001, 10:36 PM
#2
Re: Variant Array to single line Text file
what you need to do is to join the array into a single string and write to the text file at once like this
Dim v As Variant
dim s as string
s = ""
For Each v In input1
s = s + cstr(v)
Next
Print #1, s
-
May 8th, 2001, 09:19 AM
#3
Re: Variant Array to single line Text file
You can use the Join() function. It returns a string created by joining a number of substrings contained in an array. And you can optionally specify a delimiter too.
-
May 8th, 2001, 09:36 AM
#4
Re: Variant Array to single line Text file
Dim v() As Variant
ReDim Preserve v(4)
v(0) = "This"
v(1) = "is"
v(2) = "a"
v(3) = "Test"
Dim str As String
str = Join(v, " ")
Print str
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
|