|
-
Mar 30th, 2009, 09:21 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] interface question
hi all,
i created an Interface named IChildCommands.
implemented this in my form.
when executing procedures of this interface, i use
Code:
DirectCast(Me.ActiveMdiChild, IChildCommands).Something
i'm trying to look for a way to pass DirectCast(Me.ActiveMdiChild, IChildCommands) to an object so that i wouldn't be typing it all each time i want to use it.
i want to do something like
Code:
Dim mychild As New Object = DirectCast(Me.ActiveMdiChild, IChildCommands)
but the above code is wrong and i only used object as an example. in reality, i have no clue what variable type to use for this.
please help.
thanks.
Last edited by adshocker; Mar 30th, 2009 at 09:36 PM.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 30th, 2009, 09:41 PM
#2
Re: interface question
Of course you use type IChildCommands:
vb.net Code:
Dim mychild As IChildCommands = DirectCast(Me.ActiveMdiChild, IChildCommands)
-
Mar 30th, 2009, 09:51 PM
#3
Thread Starter
Hyperactive Member
Re: interface question
 Originally Posted by jmcilhinney
Of course you use type IChildCommands:
vb.net Code:
Dim mychild As IChildCommands = DirectCast(Me.ActiveMdiChild, IChildCommands)
hi,
thanks for the reply...
i'm having a problem doing the suggested above...
i now have the same thing you have
Code:
Dim mychild As IChildCommands = DirectCast(Me.ActiveMdiChild, IChildCommands)
but the in the command
Code:
DirectCast(Me.ActiveMdiChild, IChildCommands)
the bolded IChildCommands is underlined blue and says the "Type IChildCommands is not defined. The intellisense is picking it up though. not sure why it says its not defined.
thanks.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 30th, 2009, 09:57 PM
#4
Thread Starter
Hyperactive Member
Re: interface question
never mind... i figured it out...
it seems that i can't declare it outside of a sub like that.
i had to declare
Code:
Private mychild As IChildCommands
outside the sub and in the form_load i had to assign it
Code:
mychild = DirectCast(Me.MdiParent, IChildCommands)
don't know why though.
thanks again..
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|