Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello, i am now researching on vb
i'm now trying to make a simple code..
to pop out a "hello world" msgbox by click on the button
i add the button on my form by using array
here is my sample code
<pre lang="vb">
Dim ButArr As System.Windows.Forms.Button() = New Button(0) {}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ButArr(0) = New Button
        ButArr(0).Height = 50
        ButArr(0).Width = 100
        ButArr(0).Top = 70
        ButArr(0).Left = 200
        ButArr(0).FlatStyle = FlatStyle.Flat
        ButArr(0).ForeColor = Color.WhiteSmoke
        ButArr(0).BackColor = Color.DarkViolet
        ButArr(0).Text = "Hello World"
        Controls.Add(ButArr(0))
    End Sub

now i m wondering how should i start my command..
Posted
Updated 27-Mar-14 18:32pm
v2

1 solution

nvm i found the solution by adding this function

VB
AddHandler ButArr(0).Click, AddressOf ClickHandler



and then

VB
Public Sub ClickHandler(ByVal sender As Object, ByVal e As  _
   System.EventArgs)
        MsgBox("Hello World")
    End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900