Passing Variables By Value or Reference

Introduction

I will here attempt to elaborate on the values of calling functions and other statements with variables defined By Value or By Reference. As a beginner one may find oneself rather confused by the different options and what impact they really have on the application you are currently engineering. In my personal experience, being referred to in many cases as a "speed freak, better off in another language than VB", I look to the issues of speed in execution.

We all know how tedious many tasks may seem when it comes to VB and the lack of really fast code to perform the simplest of efforts. Much more so when you call recursive loops or several If or For loops.

One step you may take is to choose a proper way of defining the reference point and fastest way for your program to use the values of your constants and variables. This is done by A) selecting the proper Variable Type and B) by defining the variable ByVal or ByRef, when calling following statements.

The ByVal and ByRef Keywords are used in relation to the following statements.

Call, Declare, Function, Property Get, Property Let, Property Set, Sub

In this tutorial/article I will only briefly describe the intricate details of these two keywords, in reference to the Function statement. The same applies to the others as well but for simplicity I will only use the most common here.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Owning a computer without programming is like having a kitchen and using only the microwave oven” - Charles Petzold