A probable simple question?!
How can I print an array to a txt file ??
Code:Dim str(5) as string
for i=1 to 5
str(i) = i
next
open filename for output as #1
print #1, str( :confused: )
close #1
Printable View
A probable simple question?!
How can I print an array to a txt file ??
Code:Dim str(5) as string
for i=1 to 5
str(i) = i
next
open filename for output as #1
print #1, str( :confused: )
close #1
VB Code:
Dim str(5) As String For i = 1 To 5 str(i) = i Next Open FileName For Output As #1 For i = 1 To 5 Print #1, str(i) Next Close #1
Almost.....try this
Dim str(5) as string
open filename for output as #1
for i=1 to 5
print #1, str(i)
next
close #1
wouldn't
for i = 1 to ubound(str)
be better?
just in case
i mean, i know that your examples work fine, but i'm just making a suggestion ;)
- sorry, wrong thread
i think it's just a random question that he wants an answer for :p
mm.. yes, or maybeQuote:
Originally posted by da_silvy
wouldn't
for i = 1 to ubound(str)
be better?
just in case
i mean, i know that your examples work fine, but i'm just making a suggestion ;)
for i = LBound(str) to UBound(str)
yes
maybe not for this example, but it will help him in the future ;)
K, we all like this sort of thing written for us, and in case you guys
havent noticed, the ol' macai dude likes it in Sub\Func format.There ya' go! Nice and neat and tidy, for theVB Code:
Public Sub ArrayText(TextArray(), _ FileName as String, _ Optional FileNum As Byte = 1, _ Optional CloseOnDone As Boolean = True) Dim Text As String For i = LBound(TextArray) To UBound(TextArray) Step 1 Text = Text & TextArray(i) & Chr(10) & Chr(10) Next i Open FileName For Output As #FileNum Write #FileNum, Text If CloseOnDone = True Then Close #FileNum End Sub
PCreyght Meista'!
Have a good one, guys.
Laterz