Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does := mean in vb.net?

We have this method call:

SendAck(AppData:=AppData, Status:=Status, StatusMessage:=StatusMessage, IsApplication:=IsApplication)

And here is the definition:

Private Sub SendAck(ByVal AppData As XDocument, ByVal Status As Boolean, ByVal StatusMessage As String, ByVal IsApplication As Boolean)

Why does the call have the parameters with the ":=". I'm just curious.

like image 460
Scott Avatar asked Oct 29 '10 20:10

Scott


People also ask

What symbol is used in VB.NET to assign values to a variable?

An operator is a symbol (e.g., = , + , > , & ) that causes VB.NET to take an action. That action might be an assignment of a value to a variable, the addition of two values, a comparison of two values, concatenation of strings, etc.

What is VB expression?

An expression is a collection of two or more terms that perform a mathematical or logical operation. The terms are usually either variables or functions that are combined with an operator to evaluate to a string or numeric result.


1 Answers

The ":=" in VB.Net is used to pass a function argument by name. The default is by position. It allows for parameters to be called in any order and determines the positioning based on name matches.

For example

Sub Example(ByVal param1 as Integer, ByVal param2 As Integer) 
  Console.WriteLine("{0} - {1}", param1, param2)
End Sub

Example(param2:=42, param1:=1) ' Prints "1 - 42"
Example(42, 1)                 ' Prints "42 - 1"
like image 128
JaredPar Avatar answered Oct 02 '22 01:10

JaredPar