1. Constructs: Is a method that runs when a new instance at class is created. It is called Sub New. Sub New may have arguments. Constructs may be overloaded.





    Events: Different from VB6.
    Class ClassName
    Event EventName ( .. )

    RaiseEvent EventName ( .. )
    End Class


    Trapping Events with WithEvents:
    Module MainMode
    Dim WithEvents EventName As New EventType
    :
    Sub SubName
    EventName ( .. )
    End Sub
    End Module.


    Constructors and Destructors

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
    System.EventArgs) Handles Button1.Click
    Dim oClass As ThisClass = New ThisClass()
    oClass.Dispose()
    oClass = Nothing
    End Sub
    End Class

    Public Class ThisClass

    Public Sub New()
    MessageBox.Show("NEW")
    End Sub


    Protected Overrides Sub Finalize()
    MyBase.Finalize()
    MessageBox.Show("Finalize")
    End Sub

    Protected Sub Dispose()
    MessageBox.Show("Dispose")
    End Sub
    End Class




    The Finalize is not called right away, it is called when ever the garbage collector needs to clean up the memory (or when the app is closed). So to get around the problem programmers create a function called dispose and call it explicitly.

    System.GC: Lets you access the garbage collection programmatically. However, this may slow down the application.

    0

    Add a comment

Blog Archive
Topics
Topics
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.