Home All Groups Group Topic Archive Search About

Purpose of Keyword "Overloads"?

Author
12 Apr 2006 3:53 PM
Arthur Dent
Hi all,

Im just curious, what is the purpose of the keyword "Overloads" in VB
nowadays?
I understand conceptually what overloads are and what they do, but im a
little puzzled,
because if you declare two subs or properties or functions with the same
name but
different signatures, it seems to overload them without any problem anyway,
so why
is the keyword there?
Does using the keyword just work as some sort of compiler hint or something
or ?

Cheers!
- Arthur Dent.

Author
12 Apr 2006 6:10 PM
Vijay
Its just there... a optional use... no big deal if you use it or if you
don't...

Vijay

Show quoteHide quote
"Arthur Dent" <hitchhikersguideto-n***@yahoo.com> wrote in message
news:eT1x1kkXGHA.3724@TK2MSFTNGP02.phx.gbl...
> Hi all,
>
> Im just curious, what is the purpose of the keyword "Overloads" in VB
> nowadays?
> I understand conceptually what overloads are and what they do, but im a
> little puzzled,
> because if you declare two subs or properties or functions with the same
> name but
> different signatures, it seems to overload them without any problem
> anyway, so why
> is the keyword there?
> Does using the keyword just work as some sort of compiler hint or
> something or ?
>
> Cheers!
> - Arthur Dent.
>
Author
12 Apr 2006 6:30 PM
Herfried K. Wagner [MVP]
"Vijay" <vi***@msdiscussions.com> schrieb:
> Its just there... a optional use... no big deal if you use it or if you
> don't...

IIRC 'Overloads' is not always optional (see documentation).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
13 Apr 2006 3:01 AM
rmacias
Here's a simple example on where teh Overloads keyword is necessary:

Public MustInherit Class Class1

    Public MustOverride Sub Method1()
    Public MustOverride Sub Method1(ByVal x As Integer)
    Public MustOverride Sub Method1(x as Integer, y as String

End Class

Public Class Class2
    Inherits Class1

    Public Overloads Overrides Sub Method1()

    End Sub

    Public Overloads Overrides Sub Method1(ByVal x As Integer)

    End Sub

    Public Overloads Overrides Sub Method1(ByVal x As Integer, ByVal y As
String)

    End Sub
End Class

In the "Class2" definition, the "Overloads" keyword is necessary or your
code will not compile.

Show quoteHide quote
"Arthur Dent" wrote:

> Hi all,
>
> Im just curious, what is the purpose of the keyword "Overloads" in VB
> nowadays?
> I understand conceptually what overloads are and what they do, but im a
> little puzzled,
> because if you declare two subs or properties or functions with the same
> name but
> different signatures, it seems to overload them without any problem anyway,
> so why
> is the keyword there?
> Does using the keyword just work as some sort of compiler hint or something
> or ?
>
> Cheers!
> - Arthur Dent.
>
>
>