Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 23rd, 2006, 9:00 AM   #1
Ithaqua
Newbie
 
Join Date: Oct 2005
Location: The othe side
Posts: 19
Rep Power: 0 Ithaqua is on a distinguished road
Class problem

I have a problem in that I have created this class below it is designed to allow the user to set the full path to a file and store that data in the variable fullPath, but when I try to retreive that data in the fullPath variable and try to use it in the main program

Quote:
Public Class FileDetails

Private fullPath as string ' Holds the full path and filename of the file

ReadOnly Property FullPathAndFilename() As String
Get
Return _fullPath
End Get
End Property

End Class
The class is called in the main program like this.
Quote:
' Create a new instance of the class that holds files details
Dim MyFileDetails As FileDetails
MyFileDetails = New FileDetails

' Read in the data from the file
Dim objReader As StreamReader = New StreamReader(MyFileDetails.FullPathAndFilename)
Strangley if I try and put the data in the fullPath varible into a message box in the main program it shows the there is data there.

Can any one help?
__________________
Cheers
Ithaqua
Ithaqua is offline   Reply With Quote
Old Oct 29th, 2006, 10:51 PM   #2
XanFox
Newbie
 
XanFox's Avatar
 
Join Date: Oct 2006
Location: Australia - Gold Coast
Posts: 8
Rep Power: 0 XanFox is on a distinguished road
Hi,

I am not quite sure what you are trying to do here exactly...(and I am a novice ..)

The FileDetails class has a private string to hold the file address in, but it only seems to have one method... a get (an accessor). If you want to specify the file path wouldn't you need to set it? Also in your main program wouldnt you then need to call on the get method to get that address string?
__________________
Everything works out in the End...so if its not all worked out...your not at the end!
XanFox is offline   Reply With Quote
Old Oct 30th, 2006, 3:58 AM   #3
Iftikhar
Programmer
 
Iftikhar's Avatar
 
Join Date: Oct 2006
Location: London
Posts: 40
Rep Power: 0 Iftikhar is on a distinguished road
Send a message via MSN to Iftikhar
I am not sure what you are trying to achieve here. YOu have a property which is read only. So you can not allow a user to set full path through it. you can only get what ever is in the fullpath variable.
If you set it up earlier then there could be some other problems. You have not mentioned what kind of error it is generating. File not found or like that.
__________________
Iftikhar Ahmed Khan
For doing an experiment on programmer's mood please visit http://uxisfyp1.brunel.ac.uk/cspgiak
Iftikhar is offline   Reply With Quote
Old Oct 30th, 2006, 7:46 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
@Iftikhar: This has been mentioned before, but perhaps you don't get it.
Quote:
Originally Posted by Signatures Rule #3
Font size - Please don’t increase font size beyond the default text size.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Dec 5th, 2006, 5:30 PM   #5
BlackDal
Newbie
 
Join Date: Feb 2006
Posts: 12
Rep Power: 0 BlackDal is on a distinguished road
your property in class is read-only! why?
you can make it read-write...
Property FullPathAndFilename() As String
set(vaslue as string)
   _fullPath = value
end set
Get
Return _fullPath
End Get
End Property
BlackDal is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
rs232 class problem Brent C++ 3 Jun 29th, 2006 6:38 PM
1 class, 1 problem = 1 big headache Eric the Red Java 7 May 24th, 2006 12:49 AM
Problem with class constructor paeck C++ 8 Feb 7th, 2006 1:53 PM
problem with user defined class mixed with functions willj729 C++ 4 Oct 9th, 2005 4:26 PM
MFC/OpenGL: problem with 'Document' class brenda C++ 11 May 23rd, 2005 9:10 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:45 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC