Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default write 1-dimensional array of integers to text file

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default write 1-dimensional array of integers to text file

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

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"RB Smissaert" wrote in message
...
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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default write 1-dimensional array of integers to text file

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

RBS


"Dick Kusleika" wrote in message
...
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

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"RB Smissaert" wrote in message
...
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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default write 1-dimensional array of integers to text file

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

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

RBS


"Dick Kusleika" wrote in message
...
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

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"RB Smissaert" wrote in message
...
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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write to Array from other closed Excel file Dave B[_4_] Excel Programming 5 October 1st 03 04:48 PM
add to two dimensional array GUS Excel Programming 1 August 26th 03 12:12 AM
2 Dimensional Array Tom Ogilvy Excel Programming 0 August 18th 03 08:04 PM
2 Dimensional Array steve Excel Programming 0 August 18th 03 07:19 PM
Sorting a 2-dimensional array Vasant Nanavati[_2_] Excel Programming 3 July 12th 03 08:27 PM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"