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

Visual Basic

 
GeneralRe: A C# DLL produce error on VB.net project Pin
dilkonika2-Feb-15 9:59
dilkonika2-Feb-15 9:59 
QuestionMicrosoft.Office.Interop.Excel.Application and pictures Pin
jkirkerx2-Feb-15 8:11
professionaljkirkerx2-Feb-15 8:11 
AnswerRe: Microsoft.Office.Interop.Excel.Application and pictures Pin
Kenneth Haugland3-Feb-15 8:14
mvaKenneth Haugland3-Feb-15 8:14 
General[Heading over to the Microsoft Forum for this] Pin
jkirkerx3-Feb-15 9:24
professionaljkirkerx3-Feb-15 9:24 
QuestionEntity Framework : Filter child entities Pin
dilkonika31-Jan-15 7:15
dilkonika31-Jan-15 7:15 
AnswerRe: Entity Framework : Filter child entities Pin
Kenneth Haugland31-Jan-15 21:35
mvaKenneth Haugland31-Jan-15 21:35 
GeneralRe: Entity Framework : Filter child entities Pin
dilkonika1-Feb-15 5:02
dilkonika1-Feb-15 5:02 
AnswerRe: Entity Framework : Filter child entities Pin
Kenneth Haugland1-Feb-15 19:09
mvaKenneth Haugland1-Feb-15 19:09 
Well, list1 is just a list of articles so you can use Linq on the rest:

   Private List1 As New List(Of Article)
    Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)

        For i As Integer = 0 To 6
            Dim f As New Article
            f.ID = 2
            f.Td = i
            List1.Add(f)
        Next
        lst.ItemsSource = List1
    End Sub

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        SearchString = "id=2, td=3"
        Dim predicate As Predicate(Of Article) = AddressOf FindArticles

        lst.ItemsSource = List1.FindAll(predicate)
    End Sub

    Dim SearchString As String = ""

    Private Function FindArticles(obj As Article) As Boolean

        Dim ListOfProperties As New List(Of String)
        Dim ValueOfProperties As New List(Of String)

        If SearchString = "" Then
            Return True
        End If

        Dim NumberOfArguments() As String
        NumberOfArguments = SearchString.Split(",")
        For Each Str As String In NumberOfArguments
            Dim test() As String = Str.Trim.Split("=")
            ListOfProperties.Add(test(0).Trim)
            ValueOfProperties.Add(test(1).Trim)
        Next

        Dim ReturnValues As New List(Of Boolean)
        '   Dim TrueValue As Boolean = False

        For Each p As System.Reflection.PropertyInfo In obj.GetType().GetProperties()
            If p.CanRead And p.CanWrite Then

                For i As Integer = 0 To ListOfProperties.Count - 1
                    If p.Name.ToLower = ListOfProperties(i).ToLower Then

                        Dim t As Type = If(Nullable.GetUnderlyingType(p.PropertyType), p.PropertyType)
                        Dim safeValue As Object = If((ValueOfProperties(i) Is Nothing), Nothing, Convert.ChangeType(ValueOfProperties(i), t))

                        'Get the value
                        Dim f = p.GetValue(obj)

                        'This would set the value
                        '  p.SetValue(p, safeValue, Nothing)

                        'Is it the same type?
                        If safeValue IsNot Nothing Then
                            If f = safeValue Then
                                ReturnValues.Add(True)
                            Else
                                ReturnValues.Add(False)
                            End If
                        Else
                            'If you end up here you have entered the wrong element type of the property
                            ' like an integer instead of a point etc
                        End If
                    End If
                Next
            End If
        Next


        Dim truevalue As Boolean = False
        ' This is And logic on the result
        If ReturnValues.Count <> 0 Then
            Dim tempvalue As Boolean = True
            For Each Bools As Boolean In ReturnValues
                tempvalue = tempvalue And Bools
            Next
            truevalue = tempvalue
        End If

        Return TrueValue
    End Function
End Class

Class Article
    Private pId As Integer
    Public Property ID() As Integer
        Get
            Return pId
        End Get
        Set(ByVal value As Integer)
            pId = value
        End Set
    End Property

    Private pTd As Integer
    Public Property Td() As Integer
        Get
            Return pTd
        End Get
        Set(ByVal value As Integer)
            pTd = value
        End Set
    End Property

End Class

GeneralRe: Entity Framework : Filter child entities Pin
dilkonika2-Feb-15 4:45
dilkonika2-Feb-15 4:45 
GeneralRe: Entity Framework : Filter child entities Pin
Kenneth Haugland2-Feb-15 4:55
mvaKenneth Haugland2-Feb-15 4:55 
GeneralRe: Entity Framework : Filter child entities Pin
dilkonika2-Feb-15 5:13
dilkonika2-Feb-15 5:13 
QuestionOverriding events in an inherited Control Pin
Sam Marrocco30-Jan-15 9:20
Sam Marrocco30-Jan-15 9:20 
AnswerRe: Overriding events in an inherited Control Pin
Mycroft Holmes1-Feb-15 11:59
professionalMycroft Holmes1-Feb-15 11:59 
QuestionUpdate a database structure according to a model Pin
dilkonika29-Jan-15 18:16
dilkonika29-Jan-15 18:16 
AnswerRe: Update a database structure according to a model Pin
Richard Deeming30-Jan-15 1:26
mveRichard Deeming30-Jan-15 1:26 
GeneralRe: Update a database structure according to a model Pin
dilkonika30-Jan-15 18:07
dilkonika30-Jan-15 18:07 
AnswerRe: Update a database structure according to a model Pin
Mycroft Holmes30-Jan-15 13:44
professionalMycroft Holmes30-Jan-15 13:44 
GeneralRe: Update a database structure according to a model Pin
dilkonika30-Jan-15 18:16
dilkonika30-Jan-15 18:16 
GeneralRe: Update a database structure according to a model Pin
Mycroft Holmes31-Jan-15 21:09
professionalMycroft Holmes31-Jan-15 21:09 
GeneralRe: Update a database structure according to a model Pin
dilkonika2-Feb-15 4:35
dilkonika2-Feb-15 4:35 
GeneralRe: Update a database structure according to a model Pin
Mycroft Holmes2-Feb-15 11:44
professionalMycroft Holmes2-Feb-15 11:44 
QuestionVB.Net programming Pin
John Schlaff28-Jan-15 16:26
John Schlaff28-Jan-15 16:26 
AnswerRe: VB.Net programming Pin
Richard Deeming29-Jan-15 1:02
mveRichard Deeming29-Jan-15 1:02 
QuestionShellExecute problem Pin
AccessDeveloper28-Jan-15 6:52
AccessDeveloper28-Jan-15 6:52 
QuestionRe: ShellExecute problem Pin
jkirkerx28-Jan-15 8:13
professionaljkirkerx28-Jan-15 8:13 

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.