KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

Global variables and subroutines

Lets do the same thing as in the last example, except we will define global variables, that is a variable defined outside a subroutine. Unlike in the previous example, if change the value of the global variable in Procedure_1 will change it everywhere and hence impact it's use in Procedure_2.

<Title> Global variable</title>
<% strGlobal="I'm a persistent script-level variable"%>
<% strGlobalChange="I'm a changing global variable"%>

<% sub Procedure_1()
strDifferent="Hi I'am strDifferent in Procedure_1"
StrGlobalChange="Changed in procedure_1"
<%End sub%>

<% sub Procedure_2()
strDifferent="Hi I'am strDifferent in Procedure_2"%>
<%End sub%>

<P> Calling Procedure 1 ..<I><%Procedure_1()%> </i></P>
<P> Calling Procedure 2 ..<I><%Procedure_2()%> </i></P>
<P> Calling Procedure 1 ..<I><%Procedure_1()%> </i></P>

How it works:

Each subroutine, Procedure 1 and procedure 2 define their own copies of strDiffernt and assign different values to thereby demonstrating how to create a local variable and the scope of that variable. They also print out the variable strGlobal which is defined outside the subroutines and hence can be seen by each subroutine. Hence the value will be the same in both. Global variable gets changed in one subroutine will impact its value every where.

ASP tutorial
What is ASP
Install IIS
VBScript or JScript
ClientSide vs ServerSide scripting
ASP execution order
Dealing with Form
More Form example
Variable &Variant
Local variable
Global variable
Use if_then_else
Use Select Case
For_Next loop
Do_while loop
Subroutine vs Function
Request Object
Count Keyword
Using QueryString
Application, Method, Events
Create Virtual Directory
Save array in Application
Session, Method, Events
Using Cookie
Server Object
Ad Rotator
Content Linker
Dictionary object
Filesystemobject Object




Best books about ASP & ASP.Net from Amazon
Beginning Dynamic Websites : with ASP.NET Web Matrix (Programmer to Programmer) (Paperback) Build Your Own ASP.NET Website Using C# & VB.NET (Build Your Own) (Paperback) Professional Active Server Pages 3.0 (Programmer to Programmer) (Paperback) ASP.NET Cookbook (Paperback) ASP.NET Kick Start (Paperback)


Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © All rights reserved(new). Privacy|Copyright
designed by

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer