":=" Syntax Within Parameter Lists

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
 
H

Herfried K. Wagner [MVP]

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top