Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Posted on 2016-08-23
Medium Priority
Last Modified: 2016-08-23
I'm new to using Interfaces.  I using  library that has an object defined as an interface.  How do I create/new an object of this type?
Question by:HLRosenberger
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
LVL 44

Expert Comment

ID: 41766931
something like
dim obj as InterfaceX = new InterfaceX

Author Comment

ID: 41766956
if I do that, I get "'New' cannot be used on an interface".
LVL 44

Accepted Solution

AndyAinscow earned 1000 total points
ID: 41766987
oops, sorry.  The new should be used on a class that is based on the interface

dim obj as InterfaceX = new classX

with the following:
Public Interface InterfaceX
    Sub IFoo()
End Interface

Public Class classX
    Implements InterfaceX

    Public Sub IFoo() Implements InterfaceX.IFoo
    End Sub
End Class
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 1000 total points
ID: 41767016
Hi HLRosenberger;

An interface is a definition of what needs to be implemented in your code to fulfill the contract of that interface. Please see this Microsoft Documentation on Interfaces (Visual Basic) for more details.

Author Closing Comment

ID: 41767438
LVL 64

Expert Comment

by:Fernando Soto
ID: 41767447
Not a problem, glad to help.

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question