Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inappropriate use of overloads

Status
Not open for further replies.

Jrhaynes

Technical User
Oct 27, 2006
21
US
I found this question has been asked in FAQ before (thread796-1070862) but not answered as the questioner provided no code. So I ask it and provide the code below.
Question: "Why does VB.Net (2005) give a Warning "Inappropriate use of overload keyword in a module"?. Checking online help and several other sources the code I am using seems to exactly meet all requirements. The module looks like this:

Option Explicit On
Option Strict On
Public Module ModIO
Public Overloads Function MyFunction (ByRef X As Boolean) As Boolean
---
End Function
Public Overloads Function MyFunction (ByRef X As String) As Boolean
---
End Function
End module

According to Help the functions must be different in one of 5 different listed ways, on of them being the parameter type as above.
 
Its only a compiler warning - not an error.

I presume the idea behind the warning is to draw your attention to the "fact"?? that overloading etc. is the preserve of classes not modules - and also, possibly, to dissuade you from using that technique in modules since MS may in a future version of VB remove the support for it??.

The important thing, though, is that the code works (as long as you are prepared to ignore compiler warnings).


Hope this helps.

[vampire][bat]
 
You should be able to omit the overloads keyword. It should only be used when using inheritance and when overloading a method in the base-class it is nor necessary to use it in the same class.

I hope this is the same for you module guys.

Christiaan Baes
Belgium

"My new site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top