Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi  Print This     

Parameters (Delphi and VB.Net Cross Reference Guide)

By Mike Prestwood

Delphi versus VB.Net: A side by side comparison between Delphi and VB.Net.

Language Details

Language Details is kind of a catch all for stuff that didn't make it into language basics nor any other category.


[Other Languages] 
Delphi:   var, const

Object Pascal allows parameters of the same type to be listed together, separated by commas, and followed with a single data type (more params of different data types can follow, after a semi-colon).

Delphi also supports default parameters (a form of overloading).

By Reference or Value (and by constant): The default for parameters is by value. For by reference, add var in front of the parameter. Object Pascal also offers constant parameters where you add const in front of the parameter. A constant parameter is like a local constant or read-only parameter the compiler can optimize. You cannot assign a value to a constant parameter, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object's properties.)

Syntax Example:
function Add(a, b: integer) : integer; 
  Result := a + b;
procedure ReplaceTime(var pDT: TDateTime; const pNewDT: TDateTime);
VB.Net:   ByVal, ByRef

By Reference or Value
For parameters, you can optionally specify ByVal or ByRef. ByVal is the default if you don't specify which is changed from VB Classic (in VB Classic, ByRef was the default).

Syntax Example:  
Private Function Add(ByRef a As Integer, _
ByRef b As Integer) As Integer
  Add = a + b
End Function

   Contact Us!
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675


Go ahead!   Use Us! Call: 916-726-5675 

©1995-2018 Prestwood IT Solutions.   [Security & Privacy]