Private Subroutines

V

Victor

In ASP, if I define a subroutine as private

Private Sub mySubroutine(arg1, arg2)

I understand that the variables I define inside the subroutine are local only to the
subroutine. If the same variable is defined outside the subroutine, it won't conflict
(right?)

What about variables that are defined outside the subroutine, but not inside? Are they
available inside the subroutine?

Thanks,

Vic
 
B

Bob Barrows [MVP]

Victor said:

I assume you mean "vbscript", not "ASP"
if I define a subroutine as private

Private Sub mySubroutine(arg1, arg2)

I understand that the variables I define inside the subroutine are
local only to the subroutine. If the same variable is defined outside
the subroutine, it won't conflict (right?)

Test it:
What about variables that are defined outside the subroutine, but not
inside? Are they available inside the subroutine?
Yes, variables assigned outside subroutines are global.

Here's a simple test:
<%
Dim x
x=1
response.write "outside - before call to foo: " & x & "<BR>"
foo
response.write "outside - after call to foo: " & x & "<BR>"
foo2
response.write "outside - after call to foo2: " & x & "<BR>"

sub foo()
dim x
x="inside foo"
response.write x & "<BR>"
end sub

sub foo2()
Response.Write "inside foo2 - initial value of x: " & x & "<BR>"
x=x+1
Response.Write "inside foo2 - final value of x: " & x & "<BR>"
end sub
%>


Do you have the vbscript documentation? If not, you can get it here:
http://tinyurl.com/7rk6
 
B

Bob Barrows [MVP]

Victor said:
Bob, this has been a BIG help to me today, THANKS!

Are there .CFM files for database stuff, like SQL? I've been looking,
can't find them.
Which database?

SQL Server (Books OnLine - aka BOL) documentation can be found here:
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

For Access, you need to use the online help.

Or are you asking for sql language help in general? I know of no generic
online source of sql assistance.
 
V

Victor

Which database?

SQL Server (Books OnLine - aka BOL) documentation can be found here:
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

For Access, you need to use the online help.

Or are you asking for sql language help in general? I know of no generic
online source of sql assistance.

SQL Server or SQL Language. Actually, I'm partial to the MS help file format because
it's easy to use and very easy search, and I can efficiently use them when my laptop is
on battery and not connected to the internet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top