PC Review


Reply
Thread Tools Rate Thread

How to create an overrides Sub or Function in VB.NET IDE?

 
 
=?Utf-8?B?U3VycmVhbGlzdA==?=
Guest
Posts: n/a
 
      16th Jul 2004
I need something likes as when I create an event procedure.
I can use top-left and top-right dropdown list of code editor
to select object and its exposed events respectively.

Then, the IDE, automatically paste the function
header (signature) for me.

But I can't find a way to see list of Sub or Function
that I can overrides such as ToString Function.

Please guide me.
TIA.
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      16th Jul 2004
Hi,

It is under overrides.

Ken
-------------------
"Surrealist" <(E-Mail Removed)> wrote in message
news:2C214CF3-4DCE-43BF-9B6A-(E-Mail Removed)...
>I need something likes as when I create an event procedure.
> I can use top-left and top-right dropdown list of code editor
> to select object and its exposed events respectively.
>
> Then, the IDE, automatically paste the function
> header (signature) for me.
>
> But I can't find a way to see list of Sub or Function
> that I can overrides such as ToString Function.
>
> Please guide me.
> TIA.



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Jul 2004
* "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)> scripsit:
> I need something likes as when I create an event procedure.
> I can use top-left and top-right dropdown list of code editor
> to select object and its exposed events respectively.
>
> Then, the IDE, automatically paste the function
> header (signature) for me.
>
> But I can't find a way to see list of Sub or Function
> that I can overrides such as ToString Function.


Select "(Overrides)" in the left combobox, and then the method you want
to override in the right combobox (works for 'ToString').

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
=?Utf-8?B?U3VycmVhbGlzdA==?=
Guest
Posts: n/a
 
      16th Jul 2004
It's work fine for a Form.

But how about if I create my own class?
It's not has (Overrides) for me.

Thanks.
Surrealist.


"Herfried K. Wagner [MVP]" wrote:

> * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)> scripsit:
> > I need something likes as when I create an event procedure.
> > I can use top-left and top-right dropdown list of code editor
> > to select object and its exposed events respectively.
> >
> > Then, the IDE, automatically paste the function
> > header (signature) for me.
> >
> > But I can't find a way to see list of Sub or Function
> > that I can overrides such as ToString Function.

>
> Select "(Overrides)" in the left combobox, and then the method you want
> to override in the right combobox (works for 'ToString').
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>

 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      16th Jul 2004
"Surrealist" <(E-Mail Removed)> wrote in message
news:2D3486D1-D6CC-4DEB-9148-(E-Mail Removed)...
> It's work fine for a Form.
>
> But how about if I create my own class?
> It's not has (Overrides) for me.


I suspect you only see an Overrides section when there's something
to override. You need to declare the methods in your Base class as
Overridable, as in

[Base1.vb]
Public Class Base1
Public Overridable Sub Pop()
. . .
End Sub
End Class

[Derived1.vb]
Public Class Derived1
Inherits Base1

Public Overrides Sub Pop()
. . .
End Sub

End Class

HTH,
Phill W.

>
> Thanks.
> Surrealist.
>
>
> "Herfried K. Wagner [MVP]" wrote:
>
> > * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)>

scripsit:
> > > I need something likes as when I create an event procedure.
> > > I can use top-left and top-right dropdown list of code editor
> > > to select object and its exposed events respectively.
> > >
> > > Then, the IDE, automatically paste the function
> > > header (signature) for me.
> > >
> > > But I can't find a way to see list of Sub or Function
> > > that I can overrides such as ToString Function.

> >
> > Select "(Overrides)" in the left combobox, and then the method you want
> > to override in the right combobox (works for 'ToString').
> >
> > --
> > Herfried K. Wagner [MVP]
> > <URL:http://dotnet.mvps.org/>
> >



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Jul 2004
* "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)> scripsit:
> It's work fine for a Form.
>
> But how about if I create my own class?
> It's not has (Overrides) for me.


Mark the methods as 'Overridable'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
=?Utf-8?B?U3VycmVhbGlzdA==?=
Guest
Posts: n/a
 
      16th Jul 2004
Thanks for all that participate in solving my problem.

I still have a question that did not solved.
I'll list my understanding and please let me know if somethings incorrect.

- Every class must has a based class and its root must be System.Object.
- In System.Object has ToString method that overridable.
- So, If I declare a class without Inherits clause.
Does it inherits from System.Object by default? Why it does not show
(Overrides) section in "Class Name" dropdown list.

Public Class Person
Public FirstName, LastName As String

' ---- How can I create an overrides function of System.Object.ToString here,
' ---- with helpping from Visual Studio .Net IDE?

' ---- Which I currently know is _manually_ type the function header
' ---- with a correct signature as this:
Public Overrides Function ToString() As String
Return FirstName & " " & LastName
End Function

End Class


Thank again,
Surrealist.


"Herfried K. Wagner [MVP]" wrote:

> * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)> scripsit:
> > It's work fine for a Form.
> >
> > But how about if I create my own class?
> > It's not has (Overrides) for me.

>
> Mark the methods as 'Overridable'.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>

 
Reply With Quote
 
=?Utf-8?B?U3VycmVhbGlzdA==?=
Guest
Posts: n/a
 
      16th Jul 2004
Thanks for all that participate in solving my problem.

I still have a question that did not solved.
I'll list my understanding and please let me know if somethings incorrect.

- Every class must has a based class and its root must be System.Object.
- In System.Object has ToString method that overridable.
- So, If I declare a class without Inherits clause.
Does it inherits from System.Object by default? Why it does not show
(Overrides) section in "Class Name" dropdown list.

Public Class Person
Public FirstName, LastName As String

' ---- How can I create an overrides function of System.Object.ToString here,
' ---- with helpping from Visual Studio .Net IDE?

' ---- Which I currently know is _manually_ type the function header
' ---- with a correct signature as this:
Public Overrides Function ToString() As String
Return FirstName & " " & LastName
End Function

End Class


Thank again,
Surrealist.

"Phill. W" wrote:

> "Surrealist" <(E-Mail Removed)> wrote in message
> news:2D3486D1-D6CC-4DEB-9148-(E-Mail Removed)...
> > It's work fine for a Form.
> >
> > But how about if I create my own class?
> > It's not has (Overrides) for me.

>
> I suspect you only see an Overrides section when there's something
> to override. You need to declare the methods in your Base class as
> Overridable, as in
>
> [Base1.vb]
> Public Class Base1
> Public Overridable Sub Pop()
> . . .
> End Sub
> End Class
>
> [Derived1.vb]
> Public Class Derived1
> Inherits Base1
>
> Public Overrides Sub Pop()
> . . .
> End Sub
>
> End Class
>
> HTH,
> Phill W.
>
> >
> > Thanks.
> > Surrealist.
> >
> >
> > "Herfried K. Wagner [MVP]" wrote:
> >
> > > * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)>

> scripsit:
> > > > I need something likes as when I create an event procedure.
> > > > I can use top-left and top-right dropdown list of code editor
> > > > to select object and its exposed events respectively.
> > > >
> > > > Then, the IDE, automatically paste the function
> > > > header (signature) for me.
> > > >
> > > > But I can't find a way to see list of Sub or Function
> > > > that I can overrides such as ToString Function.
> > >
> > > Select "(Overrides)" in the left combobox, and then the method you want
> > > to override in the right combobox (works for 'ToString').
> > >
> > > --
> > > Herfried K. Wagner [MVP]
> > > <URL:http://dotnet.mvps.org/>
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?U3VycmVhbGlzdA==?=
Guest
Posts: n/a
 
      16th Jul 2004
Thanks for all that participate in solving my problem.

I still have a question that did not solved.
I'll list my understanding and please let me know if somethings incorrect.

- Every class must has a based class and its root must be System.Object.
- In System.Object has ToString method that overridable.
- So, If I declare a class without Inherits clause.
Does it inherits from System.Object by default? Why it does not show
(Overrides) section in "Class Name" dropdown list.

Public Class Person
Public FirstName, LastName As String

' ---- How can I create an overrides function of System.Object.ToString here,
' ---- with helpping from Visual Studio .Net IDE?

' ---- Which I currently know is _manually_ type the function header
' ---- with a correct signature as this:
Public Overrides Function ToString() As String
Return FirstName & " " & LastName
End Function

End Class


Thank again,
Surrealist.



"Phill. W" wrote:

> "Surrealist" <(E-Mail Removed)> wrote in message
> news:2D3486D1-D6CC-4DEB-9148-(E-Mail Removed)...
> > It's work fine for a Form.
> >
> > But how about if I create my own class?
> > It's not has (Overrides) for me.

>
> I suspect you only see an Overrides section when there's something
> to override. You need to declare the methods in your Base class as
> Overridable, as in
>
> [Base1.vb]
> Public Class Base1
> Public Overridable Sub Pop()
> . . .
> End Sub
> End Class
>
> [Derived1.vb]
> Public Class Derived1
> Inherits Base1
>
> Public Overrides Sub Pop()
> . . .
> End Sub
>
> End Class
>
> HTH,
> Phill W.
>
> >
> > Thanks.
> > Surrealist.
> >
> >
> > "Herfried K. Wagner [MVP]" wrote:
> >
> > > * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)>

> scripsit:
> > > > I need something likes as when I create an event procedure.
> > > > I can use top-left and top-right dropdown list of code editor
> > > > to select object and its exposed events respectively.
> > > >
> > > > Then, the IDE, automatically paste the function
> > > > header (signature) for me.
> > > >
> > > > But I can't find a way to see list of Sub or Function
> > > > that I can overrides such as ToString Function.
> > >
> > > Select "(Overrides)" in the left combobox, and then the method you want
> > > to override in the right combobox (works for 'ToString').
> > >
> > > --
> > > Herfried K. Wagner [MVP]
> > > <URL:http://dotnet.mvps.org/>
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgV2lsbGlhbXM=?=
Guest
Posts: n/a
 
      16th Jul 2004
Once you declare the new class, and do not explicatly inherit from System.Object, then the Overridable function of System.Object is hidden. Not sure if it is an IDE thing or a Framework thing.

I do know that you can write your own ToString function without marking it as Overrides, so I would tend to think that it is a Framework thing. I suspect that if you do not explicately inherit from System.Object that there is code to implecitely shadow the ToString, Equals and GetHashCode functions if you specify them otherwise provide the default implementation.

HTH
--
David Williams, VB.NET MVP


"Surrealist" wrote:

> Thanks for all that participate in solving my problem.
>
> I still have a question that did not solved.
> I'll list my understanding and please let me know if somethings incorrect.
>
> - Every class must has a based class and its root must be System.Object.
> - In System.Object has ToString method that overridable.
> - So, If I declare a class without Inherits clause.
> Does it inherits from System.Object by default? Why it does not show
> (Overrides) section in "Class Name" dropdown list.
>
> Public Class Person
> Public FirstName, LastName As String
>
> ' ---- How can I create an overrides function of System.Object.ToString here,
> ' ---- with helpping from Visual Studio .Net IDE?
>
> ' ---- Which I currently know is _manually_ type the function header
> ' ---- with a correct signature as this:
> Public Overrides Function ToString() As String
> Return FirstName & " " & LastName
> End Function
>
> End Class
>
>
> Thank again,
> Surrealist.
>
>
> "Herfried K. Wagner [MVP]" wrote:
>
> > * "=?Utf-8?B?U3VycmVhbGlzdA==?=" <(E-Mail Removed)> scripsit:
> > > It's work fine for a Form.
> > >
> > > But how about if I create my own class?
> > > It's not has (Overrides) for me.

> >
> > Mark the methods as 'Overridable'.
> >
> > --
> > Herfried K. Wagner [MVP]
> > <URL:http://dotnet.mvps.org/>
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Write overrides my OnClick function chanko@gmail.com Microsoft ASP .NET 1 29th May 2005 08:48 PM
"Public Overrides Declare Function" possible in any other way? Benjamin Lukner Microsoft VB .NET 0 1st Sep 2004 12:23 PM
MC++ problem with virtual function overrides and collection editor Edward Diener Microsoft VC .NET 2 31st Dec 2003 12:52 AM
Re: How to set default to TRUE: Overrides Function OnBubbleEvent(ByVal source As Object, ByVal args As EventArgs) As Boolean? David Waz... Microsoft ASP .NET 0 4th Jul 2003 08:32 PM
Overrides Function OnBubbleEvent As Boolean ---> What happens when Return True|False ? Andreas Klemt Microsoft ASP .NET 0 4th Jul 2003 01:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.