473,461 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what does := mean in visual basic .net (console application)

the code was for an overload method
console.writeline(totalprice(price:=totalprice))
the name of the method was totalprice
the parameter for it was price

but I didn't know what does := between the parameter and the function.
Nov 6 '19 #1
2 2407
SioSio
272 256MB
":=" isNamed arguments are the function of the method caller

Expand|Select|Wrap|Line Numbers
  1. 'Ex.
  2.  
  3. Public Function SampleMethod1(Optional x As Integer = 0,
  4.                               Optional y As Integer = 0,
  5.                               Optional z As Integer = 0) As Integer
  6.   Return x + y * 2 + z * 3
  7. End Function
  8.  
  9. Console.WriteLine("SampleMethod1(1,2,3):{0}", SampleMethod1(1, 2, 3))
  10. ' Output:SampleMethod1(1,2,3)=14
  11. Console.WriteLine("SampleMethod1(1,2,3):{0}", SampleMethod1(x:=1, y:=2, z:=3))
  12. ' Output:SampleMethod1(1,2,3)=14
Dec 18 '19 #2
IronRazer
83 64KB
Have a look at the msdn link below, it will explain in detail what the := symbol is used for.

Passing Arguments by Position and by Name

Basically, it is used to set the value of the arguments in your call to a Sub/Function by their parameter Names instead of setting them in their specified order, separated by commas. You will see the := used with subs and functions that have several Optional parameters.

For example, this example sub has three Optional parameters, a, b, and c.
Expand|Select|Wrap|Line Numbers
  1.     Private Sub DoSomething(Optional a As Integer = 0, Optional b As Integer = 0, Optional c As Integer = 0)
  2.  
  3.     End Sub
  4.  
You can call this sub by specifying the name of parameter you want to set. Suppose I only want to set the c parameter to a value of 10 when I call it. I can do this...
Expand|Select|Wrap|Line Numbers
  1. DoSomething(c:=10)
On the other hand, you could call this sub and separate each parameter with a comma like below, and get the same result.
Expand|Select|Wrap|Line Numbers
  1. DoSomething(,, 10)
Dec 18 '19 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Charles Hixson | last post by:
I'm getting a list that I build which when printed is displaying, well, e.g.: d = << , 'Do', 'not', 'remove', 'thi', '.', ] >> Clearly I have a problem with the truncation of the final this, but...
9
by: Jay Kim | last post by:
Hi, We're implementing a Windows application using Visual Basic .NET. One of the key features we need to implement is that we should be able to get the accurate byte offset of user selected...
9
by: plusk1008 | last post by:
I have finals next week and I am stuck on one question on my review sheet for excel. So once again I beg: Please, please, please, please, please, please, please, please, please, please someone help...
3
by: cmrhema | last post by:
Hello I have written the following in console application. My problem is I want the application running in the back. and it should check every thirty minutes and update thedatabase the problem...
3
by: cugone | last post by:
I'm looking for a way to import C# namespaces (stored in a *.cs file) into a visual basic 2005 application. I'm attempting to write an application that uses DirectX and all of the helper functions...
10
by: =?Utf-8?B?V2VuZHkgRWxpemFiZXRo?= | last post by:
Questions about creating an .net ‘executable’ 2005 that will not remained installed once a user enters some data into the application. I also want this applcation to not require any previous...
1
by: kshtjj | last post by:
Dim db As Database Dim rs As Recordset Dim WS As Workspace Dim Max As Long Private Sub Form_Load() Set WS = DBEngine.Workspaces(0) DbFile = (App.Path & "\Database\AddressBook.mdb") ...
1
by: Monica Pnade | last post by:
what does /^/ mean in perl?
1
by: murlikrishna | last post by:
i was created an application in visual basic 2010 .but need to make my application to automatically run at windows start up.i know in vb6.0 but i dont know in vb2010 i got an idea to copy the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.