Exforsys

Online Training

How to create readonly property in VB Project

This is a discussion on How to create readonly property in VB Project within the Visual Basic Tutorials forums, part of the Articles and Tutorials category; I wish to know how to create the readonly property in VB Project, because most of time my friends use ...


Go Back   Exforsys > Articles and Tutorials > Visual Basic Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-14-2007, 01:56 AM
Junior Member
 
Join Date: Feb 2007
Posts: 2
sm_amuda is on a distinguished road
Lightbulb How to create readonly property in VB Project

I wish to know how to create the readonly property in VB Project, because most of time my friends use to modify the project.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-14-2007, 06:09 AM
Junior Member
 
Join Date: Feb 2007
Posts: 1
konasani Silpa is on a distinguished road
Smile read-only-property in vb.net

If you look at Visual Basic how it handle its own object, such as form and controls, some properties can be both read and be written to. For example, you cannot modify the Height property of a ComboBox even at design time and you cannot modify the MultiSelect property of the ListBox at run time. You can also use this technique to limit the access to your class properties, thus making them read-only.

You can make a property to be read-only property by simply omitting its Property Let procedure. For example, we might add a FullName property to our Student class.

Visual Basic raises a Compile Error "Cannot assign to read-only property", because you are trying to assign a value to a read only property. Your program won't even compile or run until you delete this line of error. In addition, if we omit either the FirstName and LastName assignment statement (to be precise, omit the call of either FirstName or LastNamePropert Get), Student class will raise an error when we try to execute the read-only property FullName. The trick is every time we use FullName property, the code will check the value stored in our Private member m_FirstName and m_LastName. If either of the two property does not contain any value, there is no reason to return the value of FullName. In fact, have you ever met a person with only have a FirstName or LastName?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

« web service | query »

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Software Project Planning rjames Software Testing 1 06-01-2006 04:32 AM
WebSphere V5.0 : Create Java project... lokeshm Java 0 05-29-2006 10:19 AM
hospital mgt. project in VB cddvd Project Requests 2 01-27-2005 07:44 PM
School Project VB Required rkannan2000 Project Requests 0 09-14-2004 12:12 PM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 07:26 AM


All times are GMT -4. The time now is 12:18 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.