Implicit Late Binding

Visual Basic .NET still supports late binding. Late binding is what happens when the type of an object is general and the instance of an object is specific. For example, if you declare a variable as an Object type and initialize a Button control, assigning the Button instance to the Object variable, you are using late binding. Late binding is supported through Reflection. Listing 4.1 offers an example.

Listing 4.1. An Example of Late Binding Using Reflection
 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim C As Object C = New Button() C.Text = "Test" C.Bounds = CType(sender, Control).Bounds C.Location = New Point(C.Location.X, C.Location.Y + C.Size.Height ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.