I\'m a C# developer but I\'ve inherited a legacy VB app today with 0 documentation what so ever. I\'ve been starting to read through the code and reference the list of VB ke
For VB.Net you use shared exactly like Static is used in C#, but VB.Net has a static keyword as well and it is used to retain a variable value even after the method call has ended. So the next time you call a method it will have that previous value. MSDN has a more detailed explanation here - http://msdn.microsoft.com/en-us/library/z2cty7t8.aspx
From the link there are some interesting behaviors:
When you declare a static variable in a Shared procedure, only one copy of the static variable is available for the whole application. You call a Shared procedure by using the class name, not a variable that points to an instance of the class.
When you declare a static variable in a procedure that isn't Shared, only one copy of the variable is available for each instance of the class. You call a non-shared procedure by using a variable that points to a specific instance of the class.
The equivalent of the C# Static
method modifier is Shared
in VB.net
The closest equivalent of the C# Static
class modifier in VB.Net is a Module
The Static
keyword in VB.NET defines a local variable that exists for the lifetime of the process. There is no equivalent of this in C#.
For a great reference of comparison between the two see this link: https://www.harding.edu/fmccown/vbnet_csharp_comparison.html