SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - Properties and Object Oriented Database De...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Properties and Object Oriented Database Development with VB.NET 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 17
    2006-07-26

    Table of Contents:
  • Properties and Object Oriented Database Development with VB.NET 2005
  • The class “Emp” rewritten with properties
  • Accessing the object properties from the form
  • Using read-only properties to deal with error messages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Properties and Object Oriented Database Development with VB.NET 2005 - The class “Emp” rewritten with properties


    (Page 2 of 4 )

    Since I explained the “properties” in the previous section, we shall rewrite the class “emp” by adding properties to the fields as follows:

    Public Class Emp

        Private m_empno As String
        Private m_ename As String
        Private m_sal As Double
        Private m_deptno As Integer

        Public Property sal() As Double
            Get
                Return m_sal
            End Get
            Set(ByVal value As Double)
                If value < 0 Then
                    Throw New Exception("Salary cannot be negative")
                End If
                m_sal = value
            End Set
        End Property

        Public Property empno() As String
            Get
                Return m_empno
            End Get
            Set(ByVal value As String)
                m_empno = value
            End Set
        End Property

        Public Property ename() As String
            Get
                Return m_ename
            End Get
            Set(ByVal value As String)
                m_ename = value
            End Set
        End Property

        Public Property deptno() As Integer
            Get
                Return m_deptno
            End Get
            Set(ByVal value As Integer)
                m_deptno = value
            End Set
        End Property
    ...
    End Class

    In the current case, I included validation for the property “sal” only.  Based on the requirements, you may need to add a few more validations to a few more properties accordingly. 

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. Now you can dip into developing properties in Visual Basic.NET....
     

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway