473,770 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing an interface?

I'm new to VB.NET, and I am translating an object model from C# to VB.NET,
and I have come across an odd problem implementing an interface.

The interface is a custom interface, IDrillDown, which declares one
read-only property with the following VB.NET signature:

Public ReadOnly Property ActiveText() As String

I have declared the interface in the class declaration, like this:

Public Class CustomerItem
Implements IDrillDown

...

End Class

Later in the class, I implement the interface by by declaring my ActiveText
property:

Public ReadOnly Property ActiveText() As String
Get
Return Me.Name
End Get
End Property

VB.NET is giving me a compile-time error, saying that the class must
implement the ActiveText property for the IDrillDown interface. Needless to
say, I am puzzled, since I have implemented the property with the signature
required by the interface.

Can anyone shed some light on this? Thanks.

--
David Veeneman
Foresight Systems
Aug 23 '06 #1
3 1667

David Veeneman domain is my last name wrote:
I'm new to VB.NET, and I am translating an object model from C# to VB.NET,
and I have come across an odd problem implementing an interface.

The interface is a custom interface, IDrillDown, which declares one
read-only property with the following VB.NET signature:

Public ReadOnly Property ActiveText() As String

I have declared the interface in the class declaration, like this:

Public Class CustomerItem
Implements IDrillDown

...

End Class

Later in the class, I implement the interface by by declaring my ActiveText
property:

Public ReadOnly Property ActiveText() As String
Get
Return Me.Name
End Get
End Property

David -

Public ReadOnly Property ActiveText() As String Implements
IDrillDown.Acti veText
Get
Return Me.Name
End Get
End Property

HTH,

--
Tom Shelton

Aug 23 '06 #2
Thanks, Tom!
Aug 23 '06 #3
David Veeneman wrote:
The interface is a custom interface, IDrillDown
Public ReadOnly Property ActiveText() As String
Public ReadOnly Property ActiveText() As String
Get
Return Me.Name
End Get
End Property

VB.NET is giving me a compile-time error, saying that the class must
implement the ActiveText property for the IDrillDown interface.
You have created a method that can implement th Interface's property,
but you haven't told VB to connect to two.
Interface implementations are explicit, so you have to add the
"Implements [Interfacename].[MethodName]" clause.

It allows you to do funny things like this :

Private ReadOnly Property Message() As String _
Implements I.ActiveText

Yes, that's a Private property, implementing a Public Interface property
with a totally /different/ name (but /same/ signature, otherwise).

HTH,
Phill W.
Aug 23 '06 #4

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

Similar topics

6
2761
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
2069
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.
3
8089
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
1157
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
7
2097
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I just make a Sub Dispose() and the CLR will know that this is the Dispose method to call when the object falls out of scope? Thanks.
2
6790
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
0
1084
by: ZA_AJR | last post by:
Hi All I have a class (aClass, derived from aBaseClass) with implements an interface IMyInterface. aClass also has a private member of type aNotherClass which raises various events. I would like a specific method within aClass to handle the event raised by the object of type aNotherClass AS WELL as implementing the method of the interface. Unfortunately, the method I've used (outlined below) causes a compiler error. Is there anyway to...
6
8519
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
3553
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
10260
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
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
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
5354
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
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.