newbie question about reading text files...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I'm completely new to Visual Basic, and am using Visual Basic 6.0. I'm
trying to make an application that reads in a text file, and then writes some
stuff to it. I have all of my forms made, and I made a class called
MyStreamReader. This is all the code I have in the class so far:

Private Sub Class_Initialize()
Imports System.IO
Private fileIn As StreamReader = New StreamReader("H:\test.txt")
End Sub

I get an expected end of statement on the '=' when I do this. Is there
something I'm leaving out? Any help would be greatly appreciated, as I
haven't been able to find it on Microsoft's site. All of the examples I
found look similar to what I've written.
 
Mike said:
I'm completely new to Visual Basic, and am using Visual Basic 6.0. I'm
trying to make an application that reads in a text file, and then writes
some
stuff to it. I have all of my forms made, and I made a class called
MyStreamReader. This is all the code I have in the class so far:

Private Sub Class_Initialize()
Imports System.IO
Private fileIn As StreamReader = New StreamReader("H:\test.txt")
End Sub

I get an expected end of statement on the '=' when I do this. Is there
something I'm leaving out? Any help would be greatly appreciated, as I
haven't been able to find it on Microsoft's site. All of the examples I
found look similar to what I've written.

Initialize 'fileIn' in your constructor:

\\\
Private m_FileIn As StreamReader

Public Sub New()
m_FileIn = New StreamReader("H:\test.txt")
End Sub
///
 
Okay, I did this:

Imports System.IO

Private Sub Class_Initialize()
Dim fileIn As StreamReader
fileIn = StreamReader("H:\test.txt")
End Sub

and I get an invalid outside procedure function and it highlights System.
Isn't this the correct syntax for an Imports statement?
 
Mike said:
Imports System.IO

Private Sub Class_Initialize()
Dim fileIn As StreamReader
fileIn = StreamReader("H:\test.txt")
End Sub

and I get an invalid outside procedure function and it highlights System.
Isn't this the correct syntax for an Imports statement?

Are you using VB6 or VB.NET? VB6 doesn't support 'Imports' and cannot use
classes defined in the .NET Framework's class library.
 
Oh, I'm using VB6. So, what is the VB6 alternative to StreamReader? I get
confused because it seems that all I can find on msdn is VB .NET stuff.
Thanks!
 
Mike,

When you ask this in a VB classic newsgroup you probably get a better answer
from a real VB.classic expert.

This one is still very active

Microsoft.public.vb.general.discussion

I hope this helps,

Cor
 
Mike said:
Oh, I'm using VB6. So, what is the VB6 alternative to StreamReader?

'Open', 'Input', 'Line Input', 'EOF', 'LOF', 'Close', ...

For VB6-related questions, consider posting to one of the groups in the
microsoft.public.vb.* groups hierarchy.
 

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

Similar Threads


Back
Top