questions about writing files

  • Thread starter Thread starter Larry Chen
  • Start date Start date
L

Larry Chen

Hi,

I want to do the following:

declare a file stream and a writer in subroutine A
and perform the actual write operation in subroutine B.

How should I do it ?

( I believe this should be simple, but I am novice to vb.net )

TIA

Larry
 
Larry Chen said:
I want to do the following:

declare a file stream and a writer in subroutine A
and perform the actual write operation in subroutine B.

\\\
Private m_Writer As StreamWriter

Private Sub A()
m_Writer = New StreamWriter(...)
B()
End Sub

Private Sub B()
m_Writer.WriteLine(...)
End Sub
///

- or -

\\\
Private Sub A()
Dim Writer As New StreamWriter(...)
B(Writer)
End Sub

Private Sub B(ByVal Writer As StreamWriter)
Writer.WriteLine(...)
End Sub
///
 
or

Private Sub A()
Private m_Writer As StreamWriter
m_Writer = New StreamWriter(...)
B()
End Sub

Private Sub B(m as StreamWriter)
m_Writer.WriteLine(...)
End Sub
 
Dennis said:
Private Sub A()
Private m_Writer As StreamWriter
m_Writer = New StreamWriter(...)
B()
End Sub

Private Sub B(m as StreamWriter)
m_Writer.WriteLine(...)
End Sub

What is missing from this picture?

<g>
LFS
 

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

Back
Top