VB.NET Class 陳述式

1 篇文章 / 0 new
author
VB.NET Class 陳述式
Class bankAccount
    Shared interestRate As Decimal
    Private accountNumber As String
    Private accountBalance As Decimal
    Public holdOnAccount As Boolean = False

    Public ReadOnly Property getBalance() As Decimal
        Get
            Return accountBalance
        End Get
    End Property
    Public WriteOnly Property setInterestRate(ByVal value As Decimal)
        Set
            interestRate = value
        End Set
    End Property
    Public Sub postInterest()
        accountBalance = accountBalance * (1 + interestRate)
    End Sub
    Public Sub postDeposit(ByVal amountIn As Decimal)
        accountBalance = accountBalance + amountIn
    End Sub
End Class
Class 規劃
Public Class UserBean
    Private _id As String
    Private _userName As String
    Private _pass As String
    '屬性讀寫
    Public Property id() As String
        Get
            Return _id
        End Get
        Set(ByVal value As String)
            _id = value
        End Set
    End Property
    '無傳回值 function
    Public Sub setUserName(ByVal value As String)
        _userName = value
    End Sub
    '有傳回值 function
    Public Function getUserName() As String
        Return _userName
    End Function
    '靜態函式
    Public Shared Function getBean(ByVal item As SqlDataReader) As UserBean
        Dim bean As New UserBean
        bean.id = item("user_id").ToString()
        bean.setUserName(item("user_name").ToString())
        Return bean
    End Function
End Class

from
http://msdn.microsoft.com/zh-tw/library/wa0hwf23.aspx
http://www.codeproject.com/Articles/8825/Object-Oriented-Programming-In-...
關鍵字: 
Free Web Hosting