Solved

Interfaces

Posted on 2016-08-23
6
28 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

23 Experts available now in Live!

Get 1:1 Help Now