473,881 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET implementing an interface question

Hi all, when I write the class below

Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.

I am running VS2003, .Net runtime 1.1, on a WinXP home computer.

Thank you
Colin
BTW: my interface looks like this and is a separate class/file in my
project.
Public Interface IVF
Function getPerson() As personDetails
End Interface
Nov 20 '05 #1
5 1675
IVCO must be the name of the Module/Class where the definition of the
function is. The IDE will put the stubs in automatically for you. Then you
must implement the interface.

Regards - OHM

Colin McGuire wrote:
Hi all, when I write the class below

Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.

I am running VS2003, .Net runtime 1.1, on a WinXP home computer.

Thank you
Colin
BTW: my interface looks like this and is a separate class/file in my
project.
Public Interface IVF
Function getPerson() As personDetails
End Interface


Regards - OHM# On**********@BT Internet.com
Nov 20 '05 #2
Sorry that should read.

IVCO must be the name of the Module/Class where the delaration of the
function is.

Regards - OHM#
One Handed Man [ OHM# ] wrote:
IVCO must be the name of the Module/Class where the definition of the
function is. The IDE will put the stubs in automatically for you.
Then you must implement the interface.

Regards - OHM

Colin McGuire wrote:
Hi all, when I write the class below

Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.

I am running VS2003, .Net runtime 1.1, on a WinXP home computer.

Thank you
Colin
BTW: my interface looks like this and is a separate class/file in my
project.
Public Interface IVF
Function getPerson() As personDetails
End Interface


Regards - OHM# On**********@BT Internet.com


Regards - OHM# On**********@BT Internet.com
Nov 20 '05 #3
* co***********@l ycos.co.uk (Colin McGuire) scripsit:
Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.


In VB.NET you need to explicitly specify the 'Implements...' . There is
no implicit implementation like in C#. Therefore, in VB.NET, more than
one method can implement a method defined in an interface, and the
method implementing the method of the interface doesn't necessarily have
to have the same name as defined in the interface.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Colin,
In addition to the other comments:

Your example seems to be inconsistent!

Given:
Public Class employee

End Class
Public Interface IVF Function getPerson() As personDetails End Interface

When Employee implements the interface you will get:
Public Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVF.getPerson
End Function
End Class
Your example has "IVCO.getPerson " which would cause a compile error!

As VB.NET requires the Implements statement in the class to signify that the
class implements the interface, plus it needs the Implements clause on each
method that implements a method of the interface. The Implements clause
allows you to rename and/or hide the method from the normal public
"interface" of the class.

For example you can do: Public Class employee
Implements IVF
Protected Function GetThePersonDet ails() As personDetails Implements IVF.getPerson
End Function
End Class
Are you perhaps confusing Implements with Inherits? As Inherits does not use
a clause on each method (function, sub, or property).

Hope this helps
Jay

"Colin McGuire" <co***********@ lycos.co.uk> wrote in message
news:ab******** *************** ***@posting.goo gle.com... Hi all, when I write the class below

Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.

I am running VS2003, .Net runtime 1.1, on a WinXP home computer.

Thank you
Colin
BTW: my interface looks like this and is a separate class/file in my
project.
Public Interface IVF
Function getPerson() As personDetails
End Interface

Nov 20 '05 #5
Jay, Herfried, OHM# thanks for your comments. I am on the right track
now and still learning more, which you will notice by me not posting
so many questions :)

Jay - thanks. The IVCO was a typo when converting my real code into
something a lot simpler for posting.

Thank you all again
Colin

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message news:<ul******* *******@TK2MSFT NGP09.phx.gbl>. ..
Colin,
In addition to the other comments:

Your example seems to be inconsistent!

Given:
Public Class employee

End Class


Public Interface IVF
Function getPerson() As personDetails

End Interface

When Employee implements the interface you will get:
Public Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVF.getPerson
End Function
End Class


Your example has "IVCO.getPerson " which would cause a compile error!

As VB.NET requires the Implements statement in the class to signify that the
class implements the interface, plus it needs the Implements clause on each
method that implements a method of the interface. The Implements clause
allows you to rename and/or hide the method from the normal public
"interface" of the class.

For example you can do:
Public Class employee
Implements IVF
Protected Function GetThePersonDet ails() As personDetails

Implements
IVF.getPerson
End Function
End Class


Are you perhaps confusing Implements with Inherits? As Inherits does not use
a clause on each method (function, sub, or property).

Hope this helps
Jay

"Colin McGuire" <co***********@ lycos.co.uk> wrote in message
news:ab******** *************** ***@posting.goo gle.com...
Hi all, when I write the class below

Private Class employee

End Class
and then add the line "Implements IVF" which is an interface I have
written, the IDE modifies my code to display

Private Class employee
Implements IVF
Public Function getPerson() As personDetails Implements
IVCO.getPerson
End Function
End Class
The interface defines a single function returning type personDetails.

My question is why is the function declaration in my private class

Public Function getPerson() As personDetails Implements
IVCO.getPerson

and just not

Public Function getPerson() As personDetails

because I already have the "Implements IVF" in the class header. In
other classes I have written, that also implement an interface, I
don't have this "Implements IVCO.getPerson" bit and I'm not sure why,
and if I remove it the compiler complains.

I am running VS2003, .Net runtime 1.1, on a WinXP home computer.

Thank you
Colin
BTW: my interface looks like this and is a separate class/file in my
project.
Public Interface IVF
Function getPerson() As personDetails
End Interface

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2762
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that the Controller classe of a Sequence Diagram should be implemented as a private class within a component. However, my Programmer has said that since the ASP code lives outside the
4
2071
by: Frank J. Reashore | last post by:
Hello Everyone, I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a method on the interface is not implemented. VB.net on the other hand generates a compile error if a method is not implemented. This helps in ensuring that all interface methods are implemented.
4
5090
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of the GetEnumerator method must be defined (one from the IDictionary interface, one from the IEnumerable interface). The first is defined as: public IDictionaryEnumerator GetEnumerator()
3
8095
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one statement to VB.NET and this is crucial: re-implementing ISerializable.GetObjectData() in the DataTable derived class so serializing the datatable derived class will call this method and not the DataTable version (which is private, so overriding is also...
0
1160
by: Yatin Bhuta | last post by:
Hi, I have an interface in vb 6.0. It has a property set member, which takes a parameter by reference. When I try to implement this interface in my vb.net project it gives me an error saying that "cannot implement property set because there is no matching property on interface". I think .NET does not allow parameter to be passed ByRef in property statements. here is my property set statement in vb 6.0 interface called IName
2
6795
by: larzeb | last post by:
I receive the following error from the compiler: ScheduledInfo' must implement 'Property AddrLine1() As String' for interface 'ICASSBatch'. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers. The interface: Public Interface ICASSBatch Property AddrLine1() As String Property BarCode() As String
3
1254
by: needin4mation | last post by:
Just learning about interfaces and had a probably simple question. If a class inherits from an Interface, does this guarantee that the class will have the methods defined in the Interface? I know this is supposed to be true from what I read, but what I'm really asking is that if a class implements an interface and it does not somewhere in that class implement the methods, properties, etc. (all of them) in that class, will that cause the...
6
8526
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer { .... } and I am trying to implement the Equals and GetHashCode methods.
5
3564
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the...
0
9926
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11095
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9552
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7108
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.