write 1-dimensional array of integers to text file

R

RB Smissaert

Having some trouble with what seems to be a simple problem.
I have to write a 1-dimensional array of integer numbers to a text file.
The output has to be in this format:

1247
8541
329125
14

Have tried all the possible combinations of write and print, but can't get
the above result.
I have no problem doing this with a 2-dimensional array.
Thanks for any advice.


RBS
 
D

Dick Kusleika

RBS

This worked

Sub WriteInt()

Dim MyArr As Variant
Dim FName As String
Dim Fnum As Long
Dim i As Long

FName = "c:\dick\ng\oct\integers.txt"
Fnum = FreeFile

MyArr = Array(1247, 8541, 329125, 14)

Open FName For Output As Fnum

For i = LBound(MyArr) To UBound(MyArr)
Print #Fnum, MyArr(i)
Next i

Close Fnum

End Sub
 
R

RB Smissaert

Thanks.
My problem was that I hadn't realised that IsMissing for function arguments
doesn't work when the argument is an integer.

RBS
 
T

Tushar Mehta

Technical nitpicking...

The IsMissing function works just fine irrespective of the data type of
the arguments. It's just that an argument of type Integer is never
'missing.'

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top