By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,260 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,260 IT Pros & Developers. It's quick & easy.

optianal argument

P: n/a
Cc
hi,
how to declare optinal argument if datatype are color
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
public sub mySub(Optional myVar as Datatype = [defaultvalue])

where Datatype is the color type and default value is, well the default
value...
"Cc" <ko*****@singnet.com.sg> wrote in message
news:eE****************@TK2MSFTNGP12.phx.gbl...
hi,
how to declare optinal argument if datatype are color

Nov 20 '05 #2

P: n/a
"CJ Taylor" <no****@blowgoats.com> schrieb
public sub mySub(Optional myVar as Datatype = [defaultvalue])

where Datatype is the color type and default value is, well the
default value...


....but the default value must be a constant expression, so it is better to
add an overloaded version like

public sub mySub()
mySub(Color.white)
end sub

;-)
--
Armin

Nov 20 '05 #3

P: n/a
Hello,

"Cc" <ko*****@singnet.com.sg> schrieb:
how to declare optinal argument if datatype are color


Optional parameters must not be structures. Create multiple overloads:

\\\
Public Overloads Sub Bla()
Bla(Color.Red)
End Sub

Public Overloads Sub Bla(ByVal Foo As Color)
Nov 20 '05 #4

P: n/a
Hello,

"CJ Taylor" <no****@blowgoats.com> schrieb:
public sub mySub(Optional myVar as Datatype = [defaultvalue])

where Datatype is the color type and default value is, well
the default value...


Optional parameters must not be structure types.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.