Question

Locked

how do I reference mulitple text streams in vb.net?

By eschmidt_1975 ·
I am long time vb6 user who is new to .net. I mainly deal with reading manipulating and writing data files. What I am trying to figure out is how do I reference multiple textstreams. In vb6 I would use the file system object and make the textstream an array. Using this method (fso as new file system object and tsOut(10) as textstream I could write to 1 of 10 text streams at a time by simply refering to the text stream # of the file that I wanted to write to. This example would be used in a situation where I have 1 input file and want to split that file in to 10 outputs based on a field in the data. This is how I would do it in vb6

dim fso as new filesystem object, tsIn as textstream, tsOut(10) as textstream, val as integer, i as integer, lineIN as string
set tsin = fso.opentextfile("C:\input.txt",forreading,false)
for i = 1 to 10 'this is assuming that i know that I will only have 10 possible values
set tsout(i) = fso.createtextfile("C:\output-" & i & ".txt",true)
next
do while not tsin.atendofstream
linein = tsin.readline
val = mid(linein,1,1) 'assuming pos 1,1 has the #'s 0-9
tsout(val).writeline
loop

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Windows Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums