11/25/2009

How to code a class in VB.net 2005

近幾年物件導向愈來愈熱門,每個語言的概念差不多但寫法都不一樣,那要怎麼寫一個VB.net的Class呢?

Imports Microsoft.VisualBasic
Imports System.Data.OleDb
Imports System.Data

Public Class Table
    Private _name As String
    Private _delSql As ArrayList
    Private _dtDel As DataTable
    Private _dsQry As DataSet

    Public Sub New(ByVal name As String)
        'constructor
        Me._name = name
        Me._delSql = New ArrayList()

    End Sub

    Public ReadOnly Property Name() As String
        Get
            Return _name
        End Get
    End Property

    Public Property DataTable() As DataTable
        Get
            Return _dtDel
        End Get
        Set(ByVal value As DataTable)
            _dtDel = value
        End Set
    End Property

    Public Sub putDelSql(ByVal sSql As String)
        If Not sSql Is Nothing Then
            _delSql.Add(sSql)
        End If
    End Sub

    Public Function getDelSql() As ArrayList
        Return _delSql
    End Function

    Public Function getDelSql(ByVal i As Integer) As String
        If i <= _delSql.Count - 1 Then
            Return _delSql(i)
        End If
        Return Nothing
    End Function

    Public Property DataSetQry() As DataSet
        Get
            Return _dsQry
        End Get
        Set(ByVal value As DataSet)
            _dsQry = value
        End Set
    End Property

End Class

沒有留言:

張貼留言