Solved

Interfaces

Posted on 2016-08-23
6
25 Views
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?
0
Comment
Question by:HLRosenberger
  • 2
  • 2
  • 2
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41766931
something like
dim obj as InterfaceX = new InterfaceX
0
 
LVL 1

Author Comment

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

Accepted Solution

by:
AndyAinscow earned 250 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
        MessageBox.Show("Foo")
    End Sub
End Class
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 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.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41767438
thanks.
0
 
LVL 62

Expert Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now