Testing VB.NET language features. Structures

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", "Structure Point")
        scripter.AddCodeLine("1", "  Public x, y As Integer")

        scripter.AddCodeLine("1", "  Public Sub New(ByVal x As Integer, ByVal y As Integer)")
        scripter.AddCodeLine("1", "    Me.x = x")
        scripter.AddCodeLine("1", "    Me.y = y")
        scripter.AddCodeLine("1", "  End Sub")
        scripter.AddCodeLine("1", "End Structure")

        scripter.AddCodeLine("1", "Module Test")
        scripter.AddCodeLine("1", "Sub Main()")
        scripter.AddCodeLine("1", "  Dim a As Point = New Point(10, 10)")
        scripter.AddCodeLine("1", "  Dim b As Point = a")
        scripter.AddCodeLine("1", "  a.x = 100")
        scripter.AddCodeLine("1", "  Console.WriteLine(b.x)")
        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-2022 Alexander Baranovsky. All rights reserved.