Results 1 to 6 of 6

Thread: Static V's Public declares

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Static V's Public declares

    What is the difference, if any, between:
    VB Code:
    1. Public Static Function Woof()
    2. Dim lngID           As Long
    3. Dim strUsername     As String
    4.     'Code here
    5. End Function
    and
    VB Code:
    1. Public Function Woof()
    2. Static lngID        As Long
    3. Static strUsername  As String
    4.     'Code here
    5. End Function
    Is there a difference is memory used for storing data, is one more economical than the other, or are they absolutely identical?
    They both have EXACTALLY the same end result...

    Woka

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    As I've understood it, they're both exactly the same - I've always used public & not found aneed for the static declaration.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    There's always a need for a static declaration
    Not very often I admit...in fact, today is the 1st time I have ever used it
    I am using the Static Varible declaration, instead of the Static function one...I was just wondering if they did the same thing in the background...

    Woka

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I must admit, I would normally use this way in my coding which I guess I should really change
    VB Code:
    1. Public lngID        As Long
    2. Public strUsername  As String
    3.  
    4. Public Function Woof()
    5.     'Code here
    6. End Function

    Can't find any memory comparisons on the net for you, sorry!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228
    Perhaps what it means is, it keeps the last result from the
    function in memory no matter what?
    Luke

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    From that side, i.e. to understand what a static variable is & it's usage, you can look this up here:

    http://msdn.microsoft.com/library/de...fvariables.asp

    He's got me interested now in the "what's more efficient/which takes up less memory to use" side of things now, I'd like to know this too...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width