RSS Forums RSS
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums

Issue with Get and Let properties in Class Module

Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 467
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 83
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro in Training

Re: Issue with Get and Let properties in Class Module

  #3  
Jul 24th, 2008
Yes, I agree dmf1978 points, Property is a special feature in VB6. It encapsulates a private member variable inside a class.

For Ex
'in a Class
  1. Private mLength As Integer
  2. Public Property Get Length() As Integer
  3. Length = mLength
  4. End Property
  5.  
  6. Public Property Let Length(ByVal vNewValue As Integer)
  7. mLength = vNewValue
  8. End Property
This is normal, But u can have global variable instead
  1. Public Length as Intger
Here the Problem is "you cannot restrict the Value when it is Public variable" but you can do it in Properties.

Get and Let/Set Properties represents the Same thing. SO the Compiler enforce you to the Correct Syntax.

If you want give so many Option You can go For Procedure or Function.
This is available in Other Languages to Access the private Member GetXXX() and SetXXX() Functions.
So the AboveCode Can be
  1. Private mLength As Integer
  2. Public Function GetLength() As Integer
  3. GetLength = mLength
  4. End Sub
  5. Public Sub SetLength(ByVal vNewValue As Integer)
  6. mLength = vNewValue
  7. End Sub
but you need to Mention the function name while accessing it thru object
For Ex
  1. Dim C as New Class1
  2. Dim Length as Integer
  3.  
  4. C.SetLength 100 'Instead of C.Length = 100
  5. Length = C.GetLength() 'Instead of Length = C.Length
I hope this is helpful somewhat to you.
Last edited by selvaganapathy : Jul 24th, 2008 at 11:22 pm.
KSG
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:03 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC