Click here to Skip to main content
15,920,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: test compile mode versus production compile mode Pin
dcof7-Jan-19 9:42
dcof7-Jan-19 9:42 
GeneralRe: test compile mode versus production compile mode Pin
Richard MacCutchan7-Jan-19 9:50
mveRichard MacCutchan7-Jan-19 9:50 
GeneralRe: test compile mode versus production compile mode Pin
dcof8-Jan-19 6:17
dcof8-Jan-19 6:17 
Questioncall a Sub with a dynamic type parameter. Pin
desanti2-Jan-19 11:03
desanti2-Jan-19 11:03 
AnswerRe: call a Sub with a dynamic type parameter. Pin
Richard MacCutchan2-Jan-19 22:10
mveRichard MacCutchan2-Jan-19 22:10 
GeneralRe: call a Sub with a dynamic type parameter. Pin
desanti3-Jan-19 4:35
desanti3-Jan-19 4:35 
GeneralRe: call a Sub with a dynamic type parameter. Pin
Richard MacCutchan3-Jan-19 6:33
mveRichard MacCutchan3-Jan-19 6:33 
GeneralRe: call a Sub with a dynamic type parameter. Pin
Dave Kreskowiak3-Jan-19 6:36
mveDave Kreskowiak3-Jan-19 6:36 
Both of your "type1" and "type2" classes have fields in common. Ok, so those have to be broken out into something that is common between those two types, either an Interface implementation or a base class that they both inherit from.

You will then be able to pass your "type1" and "type2" class instances as either that interface or base class for the method to use. For example, an interface version would look something like:
VB.NET
Public Interface SomeInterface
    Property SomeProperty As String
    Property AnotherProperty As Int
End Interface

And both of your "types" would have to implement the interface:
VB.NET
Public Class Type1 Implements SomeInterface
...
End Class

Public Class Type2 Implements SomeInterface
...
End Class

When you define your method that has to accept instances of these two classes, you use the interface to define the parameter expected:
VB.NET
    Public Sub MyMethod(ByVal parameter As SomeInterface)
End Sub

The method is saying "I need something that implements this interface". It's a contract where the method expects the object passed in as "parameter" to implement a know interface, guaranteeing the properties defined in the interface will be there in the object that is passed in.

When you go to call this method, you're saying this is an instance of Type1, but since it implements this interface, treat this object as this interface type, not as the Type1 class.
VB.NET
    Dim myInstance As New Type1
...
    MyMethod(myInstance)


AnswerRe: call a Sub with a dynamic type parameter. Pin
Eddy Vluggen2-Jan-19 22:14
professionalEddy Vluggen2-Jan-19 22:14 
GeneralRe: call a Sub with a dynamic type parameter. Pin
desanti3-Jan-19 4:35
desanti3-Jan-19 4:35 
GeneralRe: call a Sub with a dynamic type parameter. Pin
Ralf Meier17-Jan-19 0:34
mveRalf Meier17-Jan-19 0:34 
QuestionDirecotoryServices - Find all Windows 7 and Windows 10 Computers in Domain Pin
Member 1186689325-Dec-18 6:43
Member 1186689325-Dec-18 6:43 
AnswerRe: DirecotoryServices - Find all Windows 7 and Windows 10 Computers in Domain Pin
Eddy Vluggen2-Jan-19 23:02
professionalEddy Vluggen2-Jan-19 23:02 
QuestionThreading, Invoke, Delegate and MethodInvoker... Pin
Member 1111281423-Dec-18 3:03
Member 1111281423-Dec-18 3:03 
AnswerRe: Threading, Invoke, Delegate and MethodInvoker... Pin
Eddy Vluggen23-Dec-18 10:52
professionalEddy Vluggen23-Dec-18 10:52 
GeneralRe: Threading, Invoke, Delegate and MethodInvoker... Pin
Member 1111281423-Dec-18 11:09
Member 1111281423-Dec-18 11:09 
GeneralRe: Threading, Invoke, Delegate and MethodInvoker... Pin
Eddy Vluggen23-Dec-18 11:14
professionalEddy Vluggen23-Dec-18 11:14 
QuestionVB Client server with timer Pin
Member 1409761321-Dec-18 21:49
Member 1409761321-Dec-18 21:49 
AnswerRe: VB Client server with timer Pin
Richard MacCutchan21-Dec-18 22:00
mveRichard MacCutchan21-Dec-18 22:00 
GeneralRe: VB Client server with timer Pin
Member 1409761321-Dec-18 22:16
Member 1409761321-Dec-18 22:16 
AnswerRe: VB Client server with timer Pin
Dave Kreskowiak22-Dec-18 4:12
mveDave Kreskowiak22-Dec-18 4:12 
QuestionHow to get a list of installed applications and uninstall them ? Pin
Lucifer Morningstar19-Dec-18 22:59
Lucifer Morningstar19-Dec-18 22:59 
SuggestionRe: How to get a list of installed applications and uninstall them ? Pin
CHill6019-Dec-18 23:07
mveCHill6019-Dec-18 23:07 
AnswerRe: How to get a list of installed applications and uninstall them ? Pin
Richard MacCutchan19-Dec-18 23:22
mveRichard MacCutchan19-Dec-18 23:22 
AnswerRe: How to get a list of installed applications and uninstall them ? Pin
Eddy Vluggen20-Dec-18 0:39
professionalEddy Vluggen20-Dec-18 0:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.