Click here to Skip to main content
16,005,491 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to run C program using .Net? Pin
Henry Minute22-Sep-09 2:22
Henry Minute22-Sep-09 2:22 
GeneralRe: How to run C program using .Net? Pin
Dave Kreskowiak22-Sep-09 3:50
mveDave Kreskowiak22-Sep-09 3:50 
GeneralRe: How to run C program using .Net? Pin
paya1pa22-Sep-09 5:37
paya1pa22-Sep-09 5:37 
GeneralRe: How to run C program using .Net? Pin
Dave Kreskowiak22-Sep-09 6:21
mveDave Kreskowiak22-Sep-09 6:21 
QuestionVoice Recognition in vb.net Pin
krinaljariwala21-Sep-09 20:09
krinaljariwala21-Sep-09 20:09 
AnswerRe: Voice Recognition in vb.net Pin
0x3c021-Sep-09 20:54
0x3c021-Sep-09 20:54 
QuestionFunction with different types of arguments Pin
TeachesOfPeaches21-Sep-09 12:36
TeachesOfPeaches21-Sep-09 12:36 
AnswerRe: Function with different types of arguments Pin
Gideon Engelberth21-Sep-09 15:44
Gideon Engelberth21-Sep-09 15:44 
Even if you could have the TypeOf ... is ... condition you were trying for, the code inside that if block will still fail. Just because you have made a check to ensure that the contents of a variable is a certain type, the compiler will still treat the variable as if it is the base type. You would need to put something like this:
VB
Private Sub GetUserInputValues(Of T)(ByRef alRemoteCustomFieldValue As List(Of T))
    ....
    If TypeOf alRemoteCustomFieldValue Is List(Of RemoteCustomFieldValue) Then                             
        'make a variable of the type just checked for and cast the original to it
        Dim customList As List(Of RemoteCustomFieldValue) = _
                CType(alRemoteCustomFieldValue, List(Of RemoteCustomFieldValue)
        Dim rcfvUsrInput As RemoteCustomFieldValue = New RemoteCustomFieldValue
        rcfvUsrInput.customfieldId = ContentCtrl.ID
        rcfvUsrInput.values = s.ToArray
        'use the cast variable
        customList.Add(rcfvUsrInput)
    Else
    ....


The problem stems mainly from the fact that generic classes cannot be converted based on the type parameter (eg: List(of Derived) cannot be converted to List(of Base)). You can however create a specialized version of the function for when T is RemoteCustomFieldValue.
VB
Private Sub GetUserInputValues(alRemoteCustomFieldValue As List(of RemoteCustomFieldValue))
    'special code for this type
End Sub


However, if you have a class SpecializedFieldValue that derives from RemoteCustomFieldValue, and you have a List(of SpecializedFieldValue), the more generic version of the function would be called.


Also, unless you intend to completely replace the list in the code that calls the function (not just Clear and Add new items), you should probably pass ByVal instead of ByRef.
NewsBackup Utility Program Pin
LaBe121-Sep-09 10:52
LaBe121-Sep-09 10:52 
GeneralRe: Backup Utility Program Pin
Henry Minute21-Sep-09 11:47
Henry Minute21-Sep-09 11:47 
GeneralRe: Backup Utility Program Pin
Dave Kreskowiak21-Sep-09 14:50
mveDave Kreskowiak21-Sep-09 14:50 
GeneralRe: Backup Utility Program Pin
LaBe123-Sep-09 15:01
LaBe123-Sep-09 15:01 
GeneralRe: Backup Utility Program Pin
Dave Kreskowiak24-Sep-09 2:10
mveDave Kreskowiak24-Sep-09 2:10 
QuestionMultiple instances of program Pin
RyJaBy21-Sep-09 6:23
RyJaBy21-Sep-09 6:23 
AnswerRe: Multiple instances of program Pin
Jay Royall21-Sep-09 6:27
Jay Royall21-Sep-09 6:27 
GeneralRe: Multiple instances of program Pin
RyJaBy21-Sep-09 7:00
RyJaBy21-Sep-09 7:00 
GeneralRe: Multiple instances of program Pin
Jay Royall21-Sep-09 21:59
Jay Royall21-Sep-09 21:59 
AnswerRe: Multiple instances of program Pin
N a v a n e e t h21-Sep-09 7:03
N a v a n e e t h21-Sep-09 7:03 
Questionxml datatype Pin
Ebube21-Sep-09 4:04
Ebube21-Sep-09 4:04 
AnswerRe: xml datatype Pin
Johan Hakkesteegt21-Sep-09 7:45
Johan Hakkesteegt21-Sep-09 7:45 
GeneralRe: xml datatype Pin
Ebube22-Sep-09 7:08
Ebube22-Sep-09 7:08 
GeneralRe: xml datatype Pin
Johan Hakkesteegt22-Sep-09 22:07
Johan Hakkesteegt22-Sep-09 22:07 
Questionchat program Pin
manisghouri21-Sep-09 3:56
manisghouri21-Sep-09 3:56 
AnswerRe: chat program Pin
Dave Kreskowiak21-Sep-09 4:01
mveDave Kreskowiak21-Sep-09 4:01 
GeneralRe: chat program Pin
manisghouri21-Sep-09 4:32
manisghouri21-Sep-09 4:32 

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.