Public Class frmLocalScope
  Inherits System.Windows.Forms.Form
  'Friend Shared MyVariable As Integer
  'Public Shared MyVariable As Integer
  Public Shared MyVariable As Integer

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  Friend WithEvents btnExit As System.Windows.Forms.Button
  Friend WithEvents btnCalc As System.Windows.Forms.Button
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.btnExit = New System.Windows.Forms.Button()
    Me.btnCalc = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'btnExit
    '
    Me.btnExit.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnExit.Location = New System.Drawing.Point(176, 120)
    Me.btnExit.Name = "btnExit"
    Me.btnExit.Size = New System.Drawing.Size(88, 23)
    Me.btnExit.TabIndex = 0
    Me.btnExit.Text = "E&xit"
    '
    'btnCalc
    '
    Me.btnCalc.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnCalc.Location = New System.Drawing.Point(16, 120)
    Me.btnCalc.Name = "btnCalc"
    Me.btnCalc.Size = New System.Drawing.Size(88, 23)
    Me.btnCalc.TabIndex = 1
    Me.btnCalc.Text = "&Calculate"
    '
    'frmLocalScope
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 205)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCalc, Me.btnExit})
    Me.Name = "frmLocalScope"
    Me.Text = "Local Scope"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim sb As New System.Text.StringBuilder(255000)
    Dim s As String

    Dim i As Integer

    For i = 1 To 17000
      sb.Append(CStr(i))
      sb.Append(",")
    Next
    s = sb.ToString

  End Sub

  Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
    Dim F2 As New frmForm2()
    Static counter As Integer
    Dim i As Integer

    counter = -5
    i = +counter
    MyVariable = 20
    counter = counter + 1
    MyVariable = counter
    F2.ShowDialog()

  End Sub

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    Me.Dispose()
  End Sub
End Class
