M
Miro
This qustion is probably for people who have created large apps with subs /
or functions that have
a lot of parameters and used in a lot of places in ur whole app. ( lets say
its ur own library function )
-Not looking for a big complicated question... ( dont waste a lot of ur time
please )
I have been searching for the "Optional" parameter forever in VB.net
I have found a pretty down to earth article on why NOT to use them....
http://www.knowdotnet.com/articles/optionalparams.html
so a simple example of doing this is:
Sub DisplayMyName(ByVal FirstName As String, Optional ByVal LastName As
String = "")
' do stuff
End Sub
So you can call this function in 1 of two ways:
DisplayMyName( "John", "" ) ' Without hte optoinal clause
or DisplayMyName( "John", "Smith" )
I havnt gotten to the point where I have created a Function or a Sub with a
bunch of parameters...
but I was wondering what do you vb.net longs do?
When you add a new paramter to the end of a Sub or a Function that would be
used everywhere in tonnes of places
in your whole application, ( lets say its like a library function ), what do
you do:
1. Go to all your Function calls and add a , "" - and dont use the
Optional Clause.
2. Or do you actually use the "Optoinal" clause - and then from then on,
any new paramter add it as an optoinal clause as well.
From the article what I am understanding is they say I should be doing #1,
but I would like to know
what 'normal' vb.net code writers do ? Once the code gets big, option1
seems like it becomes a big problem if used
in plenty of places.
Thanks,
M.
or functions that have
a lot of parameters and used in a lot of places in ur whole app. ( lets say
its ur own library function )
-Not looking for a big complicated question... ( dont waste a lot of ur time
please )
I have been searching for the "Optional" parameter forever in VB.net
I have found a pretty down to earth article on why NOT to use them....
http://www.knowdotnet.com/articles/optionalparams.html
so a simple example of doing this is:
Sub DisplayMyName(ByVal FirstName As String, Optional ByVal LastName As
String = "")
' do stuff
End Sub
So you can call this function in 1 of two ways:
DisplayMyName( "John", "" ) ' Without hte optoinal clause
or DisplayMyName( "John", "Smith" )
I havnt gotten to the point where I have created a Function or a Sub with a
bunch of parameters...
but I was wondering what do you vb.net longs do?
When you add a new paramter to the end of a Sub or a Function that would be
used everywhere in tonnes of places
in your whole application, ( lets say its like a library function ), what do
you do:
1. Go to all your Function calls and add a , "" - and dont use the
Optional Clause.
2. Or do you actually use the "Optoinal" clause - and then from then on,
any new paramter add it as an optoinal clause as well.
From the article what I am understanding is they say I should be doing #1,
but I would like to know
what 'normal' vb.net code writers do ? Once the code gets big, option1
seems like it becomes a big problem if used
in plenty of places.
Thanks,
M.