Edgar Lopez Edgar Lopez - 4 months ago 9
Vb.net Question

In vb.net whats does it mean this symbol after the parameter thats been input ":="

Here a sample

Sub callMethod()
methodName(param:="something")
End Sub

Answer

Those are called Named arguements

A named argument consists of an argument name followed by a colon and an equal sign (:=), followed by the argument value.

Named arguments are especially useful when you are calling a procedure that has optional arguments. If you use named arguments, you don't have to include commas to denote missing positional arguments. Using named arguments makes it easier to keep track of which arguments you passed and which you omitted.

Understanding Named Arguments and Optional Arguments

When you call a Sub or Function procedure, you can supply arguments positionally, in the order they appear in the procedure's definition, or you can supply the arguments by name without regard to position.

For example, the following Sub procedure takes three arguments:

Sub PassArgs(strName As String, intAge As Integer, dteBirth As Date) 
 Debug.Print strName, intAge, dteBirth 
End Sub 

You can call this procedure by supplying its arguments in the correct position, each delimited by a comma, as shown in the following example:

PassArgs "Mary", 29, #2-21-69# 

You can also call this procedure by supplying named arguments, delimiting each with a comma.

PassArgs intAge:=29, dteBirth:=#2/21/69#, strName:="Mary"