Example - Static Statement

  1. ' This example shows how to use the static keyword to retain the value of

    ' the variable i in sub Joe. If Dim is used instead of Static then i

    ' is empty when printed on the second call as well as the first.

    Sub Main

    1. For i = 1 to 2

      1. Joe 2

      Next i

    End Sub

     

    Sub Joe( j as integer )

    1. Static i

      print i

      i = i + 5

      print i

    End Sub