943,740 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 591
  • VB.NET RSS
Sep 6th, 2009
0

How to pass a file name from another class

Expand Post »
I'm trying to pull in a file name from another class... I have a three classes... My main class, a class called Transaction, and a class called Account. I have two sequential files. "CHECKING.TXT" or "SAVINGS.TXT" that I have loaded into arrays in my main class. I need to pass the proper file name to my subs and functions somehow to my OpenText(file) statement in my Account class.

I was getting a Warning - Variable 'sr' (my streamreader variable) is used before it has been assigned a value. A null reference exception could result at runtime in my Account class, but I fixed that by moving my
VB.NET Syntax (Toggle Plain Text)
  1. sr = IO.File.OpenText(file)
before my Try statement in the subs. Not sure if that was the correct way to fix it, but the warnings disappeared. I still can't get the proper filename to pass to the other class, though...

Anyone have any clue what I'm talking about? =P
Reputation Points: 10
Solved Threads: 0
Newbie Poster
staticvoyager is offline Offline
13 posts
since Apr 2009
Sep 6th, 2009
2

Re: How to pass a file name from another class

you could hand over the file name in the call of your class.
just create an overloaded New procedure like
Public Sub New (byval _file as strng)
'your code'
End Sub

and you call this calss just like
dim myClass as New Class1(_myfile)
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009
Sep 6th, 2009
0

Re: How to pass a file name from another class

Thanks! =)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
staticvoyager is offline Offline
13 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: I DON'T want to be a hack programmer...
Next Thread in VB.NET Forum Timeline: how to reset the form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC