ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   print # statement infrequently printing 0's (https://www.excelbanter.com/excel-programming/279325-print-statement-infrequently-printing-0s.html)

strataguru[_8_]

print # statement infrequently printing 0's
 
I have an output file that is not being populated correctly.

ExtractLength goes up to 18000
The messageArray array is defined from 1 to 18000
What I'm trying to do is look in an array - if there is data is offset
loopArrayCtr - print it out.


For loopArrayCtr = 1 To ExtractLength
If messageArray(loopArrayCtr) < Empty Then
Print #1, Tab(loopArrayCtr); messageArray(loopArrayCtr);
loopArrayCtr = loopArrayCtr + Len(messageArray(loopArrayCtr)) - 1
End If
Next loopArrayCtr


If there is a more simple way of printing out an array of data from
byte 1 to x to a file exactly as the data looks in the array (imagining
the data as one long string of data that will go on one line of a file)
- that would work also.

Thanks!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

print # statement infrequently printing 0's
 
Perhaps this is what you want:

http://support.microsoft.com/default...42&Product=vb6
HOWTO: Write Data to a File Using WriteFile API

Sub Tester9()
Dim messageArray() As String
extractLength = 20
ReDim messageArray(1 To extractLength)
For loopArrayCtr = 1 To extractLength
sStr = ""
For j = 1 To Rnd() * 15 + 1
sStr = sStr & Chr(Int(Rnd() * 26 + 65))
Next
messageArray(loopArrayCtr) = sStr
Next
Open "C:\Data\Array1.Txt" For Output As #1
For loopArrayCtr = 1 To extractLength
If messageArray(loopArrayCtr) < Empty Then
Print #1, Tab, messageArray(loopArrayCtr);
End If
Next loopArrayCtr

Close #1
End Sub

writes it all to one line


--
Regards,
Tom Ogilvy


strataguru wrote in message
...
I have an output file that is not being populated correctly.

ExtractLength goes up to 18000
The messageArray array is defined from 1 to 18000
What I'm trying to do is look in an array - if there is data is offset
loopArrayCtr - print it out.


For loopArrayCtr = 1 To ExtractLength
If messageArray(loopArrayCtr) < Empty Then
Print #1, Tab(loopArrayCtr); messageArray(loopArrayCtr);
loopArrayCtr = loopArrayCtr + Len(messageArray(loopArrayCtr)) - 1
End If
Next loopArrayCtr


If there is a more simple way of printing out an array of data from
byte 1 to x to a file exactly as the data looks in the array (imagining
the data as one long string of data that will go on one line of a file)
- that would work also.

Thanks!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com