By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

questions about writing files

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Larry Chen" <lc*********@comcast.net> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

P: n/a
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

"Herfried K. Wagner [MVP]" wrote:
"Larry Chen" <lc*********@comcast.net> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

P: n/a

"Dennis" <De****@discussions.microsoft.com> wrote

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

Nov 21 '05 #4

P: n/a
The m_Writer in the b() !

"Larry Serflaten" wrote:

"Dennis" <De****@discussions.microsoft.com> wrote

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

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.