Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 630023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:48:39+00:00 2026-05-13T19:48:39+00:00

What does Static mean in VB? EDIT – Code sample for reference Module Module1

  • 0

What does Static mean in VB?

EDIT – Code sample for reference

Module Module1

    Sub Main()
        Dim a = New Foo
        Dim b = New Foo
        Console.WriteLine(a.Boom)
        Console.WriteLine(a.Boom)
        Console.WriteLine(a.Boom)
        Console.WriteLine(b.Boom)
    End Sub

End Module


Class Foo
    Function Boom() As Integer
        Static callCount As Integer = 0
        callCount += 1
        Return callCount
    End Function
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:48:39+00:00Added an answer on May 13, 2026 at 7:48 pm

    It’s a way of having fields that are local to a method. Basically, the value is maintained between calls but not accessible in other parts of the class. See Static Local Variables in VB.NET for some implementation information.

    EDIT: Jonathan, you’re right that the fields don’t have to be Shared/static. If the function/sub is declared Shared, it will be a Shared/static field. Otherwise, it will be a instance field. Either way, it is persistent across calls and local to the method. The below example (to continue a theme) shows both behaviors clearly:

    Class Fibonacci
    
        Public Function FibonacciInstance() as Integer
               Static i as Integer = -1
               Static j as Integer = 1
               Dim k as Integer
    
               k = i + j
               i = j
               j = k
    
               return k
        End Function
    
        Public Shared Function FibonacciShared() as Integer
               Static i as Integer = -1
               Static j as Integer = 1
               Dim k as Integer
    
               k = i + j
               i = j
               j = k
    
               return k
        End Function
    
        Shared Sub Main()
            Dim d as Integer
            Dim a = New Fibonacci
            Dim b = New Fibonacci       
            For d = 0 to 10
                System.Console.WriteLine("a.FibonacciInstance: " & a.FibonacciInstance())
                System.Console.WriteLine("b.FibonacciInstance: " & b.FibonacciInstance())
                System.Console.WriteLine("a.FibonacciShared: " & a.FibonacciShared())
                System.Console.WriteLine("b.FibonacciShared: " & b.FibonacciShared())
            Next d
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What does it mean to have an undefined reference to a static
What does public static void mean in Java? I'm in the process of learning.
Possible Duplicate: What does “static” mean in a C program? What does the static
GWT outputs codes like this: function com_mycompany_mywebapp_client_CTest_$$init__Lcom_mycompany_mywebapp_client_CTest_2V(){ this$static} What does the $ mean, or
when they say static classes should not have state/side effects does that mean: static
What does static mean? I know public means that it can be accessed from
What does static{ //something } declared inside a class definition body mean? public class
The msdn documentation states that a static generic Queue is thread-safe. Does this mean
What does it mean when you add the static keyword to a method? public
Possible Duplicate: What does “{x:Static}” mean in XAML? In a xaml file there is:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.