This is one thing that annoys me about Visual Basic, mostly from the angle of a
VB.NET programmer trying to move to C#. Anyway.
This may get a bit confusing but try and bear with me.
The shared keyword is most similar to the static keyword in C# essentially what it means is that a method belongs to a class and not an instance of a class. So
...Class definition
Public Shared Sub foo()
'Do something
End Sub
Public Sub fooNew()
'Do something
End Sub
'end class definitnion
So now you have a Shared sub and an instance member sub that you would access like this respectively:
'Shared Member
MyNewClass.Foo()
'Instance Member
Dim c as New MyNewClass()
c.fooNew()
The static keyword, as your defintion states: A static variable continues to exist for the lifetime of the class or module in which it is defined.
So this is what it means:
Public Sub foo(i as Integer)
Static newI As Integer
Response.Write(newI.ToString())
newI = i
End Sub
and you made a call like this:
foo(15)
foo(30)
your output would be:
0
15
And Option Explicit means that the compiler forces you to declare your variables (this is the default in VS), however, if you set Option Explicit Off it is legal to do something like
Public Sub foo()
Response.Write(VarType(myUndeclaredVariable).ToStr ing())
End Sub
Which will write: object to the screen.
anyway hope that helps.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========