Custom Functions

Submitted by: 

What are custom functions?
Custom functions are functions which you have made yourself. They can be Private (only the class in which it is created can use it) or Public (any class may use it). They are able to take parameters/arguments, can return data and can be ran on separate threads.

When should you use custom functions?
Whenever you have a script which needs to be ran over and over again at different positions within your source code you should create one function to contain the script. This way, you can call the function every-time the script needs to be ran, this saves time and space.

How to create a custom function:
To create a custom function, you simply follow these steps;
- Decide whether it needs to be public, if not, choose private.
- Choose an appropriate name for the function to be named. Make it something related to the prupose it servers, this way you will not be confused with larger scripts.
- Decide which (if any) parameters it will need to take.

Once you have decided on the features the function needs to have, you can now create the function. Click inside your class but outside of any other subs or functions and type;

  1. {Privacy} Function {Function Name}({Parameters, if any})
  3. End Function

As an example;

  1. Private Function test(ByVal s As String)
  2. End Function

Then to call the function you simply type the name of the function followed by two brackets. If any parameters/arguments are required you put them inside the brackets. Example;

  1. test("Hello")


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.