|
-
Oct 15th, 2002, 05:27 AM
#1
Static V's Public declares
What is the difference, if any, between:
VB Code:
Public Static Function Woof()
Dim lngID As Long
Dim strUsername As String
'Code here
End Function
and
VB Code:
Public Function Woof()
Static lngID As Long
Static strUsername As String
'Code here
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
-
Oct 15th, 2002, 05:32 AM
#2
As I've understood it, they're both exactly the same - I've always used public & not found aneed for the static declaration.
-
Oct 15th, 2002, 05:35 AM
#3
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
-
Oct 15th, 2002, 05:45 AM
#4
I must admit, I would normally use this way in my coding which I guess I should really change 
VB Code:
Public lngID As Long
Public strUsername As String
Public Function Woof()
'Code here
End Function
Can't find any memory comparisons on the net for you, sorry!
-
Oct 15th, 2002, 05:48 AM
#5
Frenzied Member
Perhaps what it means is, it keeps the last result from the
function in memory no matter what?
-
Oct 15th, 2002, 05:52 AM
#6
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|