Posted by: Sourav | October 17, 2016

Add a control dynamically in run time using anonymous method,VB Teacher Sourav,Kolkata 09748184075


Imports System

Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim button1 As Button = New Button
button1.Text = “Click Me”

‘AddHandler button1.Click, AddressOf button1_click
‘AddHandler button1.Click, Sub(obj As Object, eventArgs As EventArgs) MessageBox.Show(“Button Clicked”)
AddHandler button1.Click, Sub() MessageBox.Show(“Button Clicked”)

Me.Controls.Add(button1)

End Sub

‘Sub button1_click()

‘    MessageBox.Show(“Hello,You have just clicked me”)

‘End Sub

End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: