":=" Syntax Within Parameter Lists

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

I've been searching for a good example of gradient graphics. I didn't find
much, but I did find the one below which I like because it looks really
simple. EXCEPT for the ":=" syntax in the parameter lists! I've never seen
that. It's impossible to do a Google search on something like that and find
anything useful. I've checked my several VB.NET books and their indices
have nothing on this syntax. The web page I found this on claimed that it
was a VB.NET example. I hope one of you can enlighten me.

Thanks, Bob

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

'local scope
Dim myGraphics As Graphics
Dim myBrush As System.Drawing.Drawing2D.LinearGradientBrush
Dim myRectangle As Rectangle

'return the current form as a drawing surface
myGraphics = Graphics.FromHwnd(hwnd:=ActiveForm().Handle)

'create a rectangle object
myRectangle = New Rectangle(x:=5, y:=5, Width:=40, Height:=50)

'draw the rectangle to the surface
myGraphics.DrawRectangle(pen:=New Pen(Color.Black), rect:=myRectangle)

'create the gradient brush
myBrush = New System.Drawing.Drawing2D.LinearGradientBrush( _
rect:=myRectangle, _
color1:=Color.White, _
color2:=Color.DarkSlateBlue, _
LinearGradientMode:= _
System.Drawing.Drawing2D.LinearGradientMode.Vertical)

'fill the rectangle using the gradient brush
myGraphics.FillRectangle(brush:=myBrush, rect:=myRectangle)

End Sub
 
eBob.com said:
I've been searching for a good example of gradient graphics. I didn't
find much, but I did find the one below which I like because it looks
really simple. EXCEPT for the ":=" syntax in the parameter lists! I've
never seen that. It's impossible to do a Google search on something
like that and find anything useful. I've checked my several VB.NET
books and their indices have nothing on this syntax. The web page I
found this on claimed that it was a VB.NET example. I hope one of you
can enlighten me.

Using named parameters is mainly useful if you are dealing with optional
parameters and only want to provide custom parameter values for some of
the parameters.

Documentation:

Passing Arguments by Position and by Name
<URL:http://msdn.microsoft.com/en-us/library/51wfzyw0.aspx>
 
Back
Top