How to pass a file name from another class

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2009
Posts: 13
Reputation: staticvoyager is an unknown quantity at this point 
Solved Threads: 0
staticvoyager staticvoyager is offline Offline
Newbie Poster

How to pass a file name from another class

 
0
  #1
Sep 6th, 2009
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
  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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 255
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 47
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: How to pass a file name from another class

 
2
  #2
Sep 6th, 2009
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)
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 13
Reputation: staticvoyager is an unknown quantity at this point 
Solved Threads: 0
staticvoyager staticvoyager is offline Offline
Newbie Poster

Re: How to pass a file name from another class

 
0
  #3
Sep 6th, 2009
Thanks! =)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC