Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Well, subject tells everything ...
I can't find what := does in VB.NET ...

Here's one example ...

SwitchDesktop(hDesktop:=p_lngHwnd)


Can anyone tell me ?

thanks :)
Posted

It's for named parameters. For example:
<br />Sub ShowMsg(ByVal a as String, ByVal b as String, ByVal c as String)<br />  MsgBox(a & b & c)<br />End Sub<br /><br />Sub Main()<br />  'Notice how a, b, and c are out of order.<br />  ShowMsg(c := "!", b := " World", a := "Hello")<br />End Sub<br />
 
Share this answer
 
Unless I am mistaken, := allows you to pass variables by name vs. by position (example below is freehand).

Example sub: sub test (byval Value1 as string, byval Value2 as integer, byval Value3 as object)

Normal way to call by position: Call sub test("value1", 2, new object)

call by name: Call sub test(Value3:= New object, Value2:=2, Value3:="doh!")


Generally you see the := used in attributes.

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900