|
-
Dec 14th, 2001, 08:16 AM
#1
Thread Starter
Lively Member
Writing an array to a txtfile
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
Life is not a problem to solve, It's a reality to experience
-
Dec 14th, 2001, 08:27 AM
#2
-= B u g S l a y e r =-
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
-
Dec 14th, 2001, 08:27 AM
#3
Addicted Member
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
-
Dec 14th, 2001, 09:18 AM
#4
Conquistador
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
-
Dec 14th, 2001, 09:19 AM
#5
Addicted Member
-
Dec 14th, 2001, 09:21 AM
#6
Conquistador
i think it's just a random question that he wants an answer for
-
Dec 14th, 2001, 09:24 AM
#7
-= B u g S l a y e r =-
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
mm.. yes, or maybe
for i = LBound(str) to UBound(str)
-
Dec 14th, 2001, 07:47 PM
#8
Conquistador
yes
maybe not for this example, but it will help him in the future
-
Dec 15th, 2001, 02:23 AM
#9
Frenzied Member
Sub routine!
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.
VB 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
There ya' go! Nice and neat and tidy, for the
PCreyght Meista'!
Have a good one, guys.
Laterz
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
|