Imports PaxScript.Net
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend scripter As PaxScripter = New PaxScripter
#Region " Windows Form Designer generated code "
'................................................................
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
scripter.Reset()
scripter.RegisterType(GetType(Form))
scripter.RegisterType(GetType(Button))
scripter.RegisterType(GetType(MessageBox))
scripter.AddModule("1", "VB")
scripter.AddCodeLine("1", "Imports System.Windows.Forms")
scripter.AddCodeLine("1", "Public Class TestClass")
scripter.AddCodeLine("1", "Public Shared Sub OnClickHandler(ByRef Sender As Object, ByRef e As EventArgs)")
scripter.AddCodeLine("1", "MessageBox.Show(sender.ToString())")
scripter.AddCodeLine("1", "MessageBox.Show(e.ToString())")
scripter.AddCodeLine("1", "End Sub")
scripter.AddCodeLine("1", "End Class")
scripter.AddCodeLine("1", "Dim f As Form = New Form()")
scripter.AddCodeLine("1", "f.Text = ""Script-defined application""")
scripter.AddCodeLine("1", "Dim b As Button = new Button()")
scripter.AddCodeLine("1", "b.Text = ""Click me""")
scripter.AddCodeLine("1", "AddHandler b.Click, AddressOf TestClass.OnClickHandler")
scripter.AddCodeLine("1", "f.Controls.Add(b)")
scripter.AddCodeLine("1", "f.ShowDialog()")
scripter.Run(RunMode.Run)
If (scripter.HasErrors) Then
MessageBox.Show(scripter.Error_List(0).Message)
End If
End Sub
End Class