I am a newbie to the world of programming and I am trying to create a form using functions to create the buttons and labels etc. The form is created with the exception that the functions passed to on button click events are not being passed correctly. For example I have a function to create a button....
function new_btn ($name, $parent, $x, $y, $l, $h, $text, $onClick){
    $object = New-Object System.Windows.Forms.Button
    $object.Location = New-Object System.Drawing.Point($x, $y)
    $Object.Size = New-Object System.Drawing.Size($l, $h)
    $Object.Text = $text
    $object.add_Click({$onClick})
    New-Variable $name -Value $object -Scope global
    (Get-Variable $parent).Value.Controls.Add((Get-Variable $name).value)
}
I then have the function that I want to run on the button click.....
function msg {
    [System.Windows.Forms.MessageBox]::Show("We are proceeding with next step.") 
}
I then call the function and feed it the parameters.......
new_btn getdbslist tab1 20 50 69 23 "Get DB's" msg
This produces the button as expected and adds it to tab1, but the on click event will not work, nothing happens at all. Any help would be very appreciated!