please dont rip this site
Microsoft® Visual Basic® Scripting Edition
Sub Statement
Language Reference |

See Also


Description
Declares the name, arguments, and code that form the body of a Sub procedure.

Syntax

[Public | Private] Sub name [(arglist)]
    [statements]
    [Exit Sub]
    [statements]
End Sub

The Sub statement syntax has these parts:

Part Description
Public Indicates that the Sub procedure is accessible to all other procedures in all scripts.
Private Indicates that the Sub procedure is accessible only to other procedures in the script where it is declared.
name Name of the Sub; follows standard variable naming conventions.
arglist List of variables representing arguments that are passed to the Sub procedure when it is called. Multiple variables are separated by commas.
statements Any group of statements to be executed within the body of the Sub procedure.

The arglist argument has the following syntax and parts:

[ByVal | ByVal] varname[( )]

PartDescription
ByValIndicates that the argument is passed by value.
ByRefIndicates that the argument is passed by reference.
varnameName of the variable representing the argument; follows standard variable naming conventions.

Remarks

If not explicitly specified using either Public or Private, Sub procedures are public by default, that is, they are visible to all other procedures in your script. The value of local variables in a Sub procedure is not preserved between calls to the procedure.

All executable code must be contained in procedures. You can't define a Sub procedure inside another Sub or Function procedure.

The Exit Sub statement causes an immediate exit from a Sub procedure. Program execution continues with the statement following the statement that called the Sub procedure. Any number of Exit Sub statements can appear anywhere in a Sub procedure.

Like a Function procedure, a Sub procedure is a separate procedure that can take arguments, perform a series of statements, and change the value of its arguments. However, unlike a Function procedure, which returns a value, a Sub procedure can't be used in an expression.

You call a Sub procedure using the procedure name followed by the argument list. See the Call statement for specific information on how to call Sub procedures.


Caution  Sub procedures can be recursive; that is, they can call themselves to perform a given task. However, recursion can lead to stack overflow.

Variables used in Sub procedures fall into two categories: those that are explicitly declared within the procedure and those that are not. Variables that are explicitly declared in a procedure (using Dim or the equivalent) are always local to the procedure. Variables that are used but not explicitly declared in a procedure are also local unless they are explicitly declared at some higher level outside the procedure.


Caution  A procedure can use a variable that is not explicitly declared in the procedure, but a naming conflict can occur if anything you have defined at the script level has the same name. If your procedure refers to an undeclared variable that has the same name as another procedure, constant or variable, it is assumed that your procedure is referring to that script-level name. Explicitly declare variables to avoid this kind of conflict. You can use an Option Explicit statement to force explicit declaration of variables.


© 1996 by Microsoft Corporation.

file: /Techref/language/asp/VBS/VBSCRIPT/396.htm, 7KB, , updated: 1996/11/22 10:12, local time: 2024/12/4 12:54,
TOP NEW HELP FIND: 
52.15.185.147:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/TECHREF/language/asp/VBS/VBSCRIPT/396.htm"> Microsoft&#174; Visual Basic&#174; Scripting Edition </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .