Library code snippets
Use Local Variables
Within subroutines and functions, you should use local variables rather
than global variables whenever possible. Local, in this case, means that
the variables are defined between the sub/function and end sub/function
statements. Within subroutines and functions, access to local variables
is faster than to global variables. Plus, it makes for cleaner and more
readable code and easier debugging.
For example, instead of writing<%
dim intCounter
function howMany
for intCounter = 1 to 100
next
howMany = intCounter
end function
response.write howMany
%>
you should write this instead:<%
function howMany
dim intCounter
for intCounter = 1 to 100
next
howMany = intCounter
end function
response.write howMany
%>
Related articles
Related discussion
-
Calling a function from ASP code
by dunk00 (3 replies)
-
GridView HyperLinkField Problem
by Paul2 (0 replies)
-
looking for help on asp
by cladironbeard (2 replies)
-
simple vb to c#, help please
by lksath (1 replies)
-
Binary Studio | software development outsourcing Ukraine
by Hexfinity (2 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
Events coming up
-
Aug
27
Model-View-Presenter (MVC) in ASP.NET
San Francisco, United States
Model-View-Presenter (MVC) in ASP.NET Presenter Clayton Peddy, Terrace Software, Inc. Details TBD
This thread is for discussions of Use Local Variables.