Tag Archives: class

Lập trình hướng đối tượng với VBS

Class LaptopComputer
    Private modOwner
    
    Private Sub Class_Initialize(  )
        'Initalization code goes here
        WScript.Echo "Hi!"
        modOwner = "Phung Van Huy"
    End Sub
    
    Private Sub Class_Terminate(  )
        'Termination code goes here
        WScript.Echo "Die!"
    End Sub
    
    
    Public Property Let CompOwner(strOwner)
        modOwner = strOwner
    End Property
    
    Public Property Get CompOwner()
        CompOwner = modOwner
    End Property
    
    Public Function GetOwner()
        GetOwner = modOwner
    End Function
End Class

Dim oLC
Set oLC = New LaptopComputer
WScript.Echo oLC.CompOwner
oLC.CompOwner = "Changed Value"
WScript.Echo oLC.GetOwner()
Set oLC = Nothing