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

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

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi,

It is under overrides.

Ken
-------------------
"Surrealist" <Su********@discussions.microsoft.com> wrote in message
news:2C**********************************@microsof t.com...
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.

Nov 20 '05 #2

P: n/a
* "=?Utf-8?B?U3VycmVhbGlzdA==?=" <Su********@discussions.microsoft.com> 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/>
Nov 20 '05 #3

P: n/a
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==?=" <Su********@discussions.microsoft.com> 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/>

Nov 20 '05 #4

P: n/a
"Surrealist" <Su********@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
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==?=" <Su********@discussions.microsoft.com> 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/>

Nov 20 '05 #5

P: n/a
* "=?Utf-8?B?U3VycmVhbGlzdA==?=" <Su********@discussions.microsoft.com> 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/>
Nov 20 '05 #6

P: n/a
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==?=" <Su********@discussions.microsoft.com> 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/>

Nov 20 '05 #7

P: n/a
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" <Su********@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
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==?=" <Su********@discussions.microsoft.com> 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/>


Nov 20 '05 #8

P: n/a
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" <Su********@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
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==?=" <Su********@discussions.microsoft.com> 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/>


Nov 20 '05 #9

P: n/a
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==?=" <Su********@discussions.microsoft.com> 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/>

Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.