BB___FUNCTION

=FUNCTION= toc

Description
> A function is a user defined routine, which returns a value to the program. The value can be a string or a numeric value. > The value to return must be assigned to a variable inside the function, which is identical to the functions name. >> Failing to do so returns 0 (for numeric functions) or "" (for string functions).

> See also, SUB and ByRef

Syntax

 * 1) function functionName$(//zero or more parameters//)
 * 2) function functionName(//zero or more parameters//)

Hints
> If a function returns a string, it must have a $ (dollar-sign) appended to the name, ie: functionName$ > Function always goes with parentheses. Even function without parameters whould have empty parentheses. > Function names are case-sencitive, just like variables. > You cannot have functions with same names but different set of parameters. > You cannot have function with same name as array (really, JB has no means of telling if a(x) array or function call)

Example
Function without parameters (still needs parentheses) code format="lb" print dummy$

function dummy$ dummy$ = time$ end function code

code format="lb" ' count the words input "Type a sentence>"; sentence$

print "There are "; wordCount(sentence$); " words in the sentence." end

function wordCount(aString$) index = 1 while word$(aString$, index) <> "" index = index + 1 wend wordCount = index - 1  'note assigning value to return end function code

Useful Functions
code format="vbnet" Place a useful function using this command here code