Testing VB.NET language features. Delegates.

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.AddModule("1", "VB")

        scripter.AddCodeLine("1", "Delegate Sub SimpleDelegate()")

        scripter.AddCodeLine("1", "Module Test")
        scripter.AddCodeLine("1", "Sub F()")
        scripter.AddCodeLine("1", "  Console.WriteLine(""Test.F"")")
        scripter.AddCodeLine("1", "End Sub")

        scripter.AddCodeLine("1", "Sub Main()")
        scripter.AddCodeLine("1", "  Dim d As SimpleDelegate = AddressOf F")
        scripter.AddCodeLine("1", "  d()")
        scripter.AddCodeLine("1", "End Sub")
        scripter.AddCodeLine("1", "End Module")

        scripter.Run(RunMode.Run)
        If scripter.HasErrors Then
            MessageBox.Show(scripter.Error_List(0).Message)
        End If
    End Sub
End Class


Copyright © 2005-2024 Alexander Baranovsky. All rights reserved.