Home All Groups Group Topic Archive Search About

changing the value of parameters in constructor

Author
26 Sep 2006 8:40 PM
nick1510
Hi,

I want to create a new constructor in a class that inherits from another...
in VB.Net

I still want to call the base class after some code has 'manipulated' the
parameters

VB is telling me i carn't as MyBase.New needs to be the first call in the
New methd....

But how else could i do this?

Do i need to create an abstract class....?

Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
password As String)

       'code that manipulates string parameters

       MyBase.New( parameter1, parameter2, parameter3 )

    End Sub

Author
27 Sep 2006 6:59 AM
Dmytro Lapshyn [MVP]
Hi,

Not sure that's gonna work in VB .NET, but give the following approach a try
(the specific parameter modifications are given for illustrative purposes
only, the key is the inline modification of the parameters):

Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
  password As String)

       MyBase.New( String.Concat(Domain, "\", username),
String.Trim(username), String.Trim(password) )


--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

Show quote
"nick1510" <nick1***@discussions.microsoft.com> wrote in message
news:F69B6CF7-C3A5-4A67-94FD-AB01E00866D4@microsoft.com...
> Hi,
>
> I want to create a new constructor in a class that inherits from
> another...
> in VB.Net
>
> I still want to call the base class after some code has 'manipulated' the
> parameters
>
> VB is telling me i carn't as MyBase.New needs to be the first call in the
> New methd....
>
> But how else could i do this?
>
> Do i need to create an abstract class....?
>
> Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
> password As String)
>
>       'code that manipulates string parameters
>
>       MyBase.New( parameter1, parameter2, parameter3 )
>
>    End Sub
>
>
>
Author
27 Sep 2006 7:06 AM
nick1510
Yes...

Of course.... ;-)

Many thanks

Show quote
"Dmytro Lapshyn [MVP]" wrote:

> Hi,
>
> Not sure that's gonna work in VB .NET, but give the following approach a try
> (the specific parameter modifications are given for illustrative purposes
> only, the key is the inline modification of the parameters):
>
> Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
>   password As String)
>
>        MyBase.New( String.Concat(Domain, "\", username),
> String.Trim(username), String.Trim(password) )
>
>
> --
> Regards,
> Dmytro Lapshyn [MVP]
> http://blogs.vbcity.com/DmytroL
>
> "nick1510" <nick1***@discussions.microsoft.com> wrote in message
> news:F69B6CF7-C3A5-4A67-94FD-AB01E00866D4@microsoft.com...
> > Hi,
> >
> > I want to create a new constructor in a class that inherits from
> > another...
> > in VB.Net
> >
> > I still want to call the base class after some code has 'manipulated' the
> > parameters
> >
> > VB is telling me i carn't as MyBase.New needs to be the first call in the
> > New methd....
> >
> > But how else could i do this?
> >
> > Do i need to create an abstract class....?
> >
> > Public Sub New(ByVal Domain As string, ByVal username As String, ByVal
> > password As String)
> >
> >       'code that manipulates string parameters
> >
> >       MyBase.New( parameter1, parameter2, parameter3 )
> >
> >    End Sub
> >
> >
> >
>
>

AddThis Social Bookmark Button