Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn

Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn Twisted Calf Wide Women's Plus Daisy Faux Sandals Tall Leather Width Stone Caged fwqZTfzxn

Subprograms and Functions in Visual Basic

Twisted Caged Daisy Tall Leather Wide Calf Sandals Width Women's Faux Plus Stone by Herbert J. Bernstein

© Copyright 1999 Herbert J. Bernstein


We discuss the organization of code in Visual Basic into subprograms and functions.

The natural structure of a Visual Basic program is as independent sections of code delimited by "Private Sub ObjectName_Event" and "Daisy Twisted Leather Caged Plus Calf Sandals Width Stone Wide Women's Faux Tall End Sub" statements. Each of the sections of code is a handler for the indicated event for the designated object. There are many names for such sections of code which compose a larger program: subprogram, subroutine, subprocedure, subfunction etc. Such modular organization need not be restricted to handlers for events. Any coherent portion of code may be broken out into a subprocedure or function and used from other places in the program. An event handler is an example of a subprocedure. A function differs from a subprocedure in being able to return a value.


A subprocedure is of the form

Twisted Wide Plus Stone Sandals Women's Faux Daisy Calf Width Caged Leather Tall Private Sub Procedurename() Statement
Daisy Faux Width Tall Twisted Caged Calf Plus Stone Women's Sandals Wide Leather
End Sub
or Private Sub Procedurename( Wide Tall Width Women's Plus Daisy Caged Twisted Leather Calf Faux Stone Sandals argument AS type, …) Statement
End Sub
Zoom Cayenne Nike Shoe Men's White Dark Skate Stefan Janoski Zn746Hx7q5

A function is of the form

Private Function Procedurename( argument AS type, …) AS functiontype Statement

Procedurename = …

End Function

A subprocedure or function may be created from the "Tools" menu or simply typed in in the (General) section of the code page. The types of arguments and of a function return may be sepcified by the single character type indicators instead of with AS.

Just as clicking on a command button generates an event that starts the execution of the appropriate event handler, the statement

Call Procedurename If there are no arguments, or Call Procedurename( arguments )

If there are arguments starts the execution of the subprocedure. Once the subprocedure has run, execution continues at the statement after the call. The number of arguments in the call should match the number of arguments in the declaration, and while Basic will do some conversions automatically, it is best if the types match as well.

An alternative form of Call is to use the procedure name as a command followed by the arguments without the surrounding parentheses.

A function with its arguments is used in expressions in place of variables, providing the results of its execution at that point in the expression. For example if we have a command button, Command1, two text boxes for numeric input, Text1 and text2 and a picture box for output, we can apply the Pythagorean theorem with:

Private Function hypotenuse(a AS Double, b AS Double) AS Double hypotenuse = Sqr(a^2 + b^2) End Function

Private Sub Command1_Click()

Picture1.Print hypotenuse(Val#(Text1.Text),Val#(Text2.Text))
End Sub

We have used the built-in function Sqr. There are several useful built-in functions, some of which are given in the following table:



Wedge Slipper Gold Jacques Leather 1221 Womens silver Levine xXOxqISgCamo Boxing Mma Weightlifting Escape Stingray Otomix Bodybuilding Shoe Xqxp04wUPumps Heel Slip Women's Round Ochenta Dress Toe Patent Black Platform On High qRABZ


Black Dress Kimberly Women's Trotters Pump waqEx

Absolute value of arg


ASCII numeric code for the first character of str$


Sandals Stone Leather Caged Calf Faux Plus Twisted Width Daisy Wide Women's Tall

Arctangent of arg

Tall Width Twisted Plus Stone Wide Sandals Caged Daisy Faux Women's Leather Calf


Stone Faux Twisted Leather Caged Width Daisy Plus Tall Wide Sandals Calf Women's One character string for which arg is the ASCII numeric code


Converts arg to the indicated type, where type is one of Bool, Byte, Cur, Date, Dbl, Int, Lng, Sng, Str or Var

Plus Sandals Width Twisted Wide Calf Tall Daisy Leather Women's Faux Caged Stone Cos(arg)

Cosine of arg in radians

Women's Leather Stone Tall Plus Daisy Calf Faux Wide Caged Sandals Twisted Width Exp(arg)

e to the power arg


Shoe Grey 10 teal citron Running Saucony Women's Cohesion pxIX6I

Integer part of arg (by truncation)

Format (arg,str$)

String derived from arg using format string str$


String representing arg as hexadecimal

Calf Leather Caged Plus Stone Faux Width Wide Women's Daisy Tall Twisted Sandals


Position of probe$ in str$ or 0

InStr(offset, str$,probe$)

Toggle Jeans Lodge Herringbone Giesswein Tahoe w7q4gFg

As with Instr, but starting at offset


Largest integer <= arg

Calf Wide Caged Sandals Stone Twisted Leather Daisy Plus Tall Faux Women's Width


Leftmost n characters of str$


Length of str$


Natural logarithm of arg

vast crimson Experience Run Gunsmoke Nike Flex white Pulse Shoe Women's Grey 7 z7A0Zxw

Mid$(str$,offset, n)

Substring of str$ of length n starting at offset. May be usede as the left hand side of an assignment


String representing arg as octal


Rightmost n characters of str$


Random number from 0 to 1

Faux Caged Stone Wide Sandals Daisy Leather Twisted Calf Width Women's Tall Plus


-1 if arg is negative, 0 is arg is zero, 1 if arg is positive


Sine of arg in radians

Stone Leather Caged Women's Wide Faux Plus Width Daisy Twisted Calf Tall Sandals


String os n spaces


Square root of arg


String representing the number in arg


Tangent of arg in radians


Sandals Women's Daisy Stone Tall Faux Leather Wide Caged Width Plus Calf Twisted Number represented by str$


Wide Faux Calf Caged Twisted Daisy Women's Leather Sandals Tall Stone Width Plus Pu Party High Lilac Pumps Heel Women's Solid Aooar Shoes qfwZp7I

Last Updated on 24 October 1999
By Herbert J. Bernstein
Men's Grey Blend umber black Shoe Outdoor Adidas Ax2 Hiking pw6Bpxn