<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to Use the Action and Predicate Delegates</title>
	<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/</link>
	<description>Articles on VB.NET and Software Development Team Leadership</description>
	<pubDate>Sat, 22 Nov 2008 07:34:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Omar</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-1018</link>
		<author>Omar</author>
		<pubDate>Mon, 10 Mar 2008 13:25:45 +0000</pubDate>
		<guid>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-1018</guid>
		<description>Simply: thank you very much!
This is the clearest example I've found.
I solved my problem with few lines of code, and first of all in an elegant manner.</description>
		<content:encoded><![CDATA[<p>Simply: thank you very much!<br />
This is the clearest example I&#8217;ve found.<br />
I solved my problem with few lines of code, and first of all in an elegant manner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-164</link>
		<author>Matt</author>
		<pubDate>Fri, 07 Sep 2007 18:13:30 +0000</pubDate>
		<guid>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-164</guid>
		<description>Thanks, that definately answers my question and saves me from banging my head any more.  Great info.</description>
		<content:encoded><![CDATA[<p>Thanks, that definately answers my question and saves me from banging my head any more.  Great info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jfrankcarr</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-163</link>
		<author>jfrankcarr</author>
		<pubDate>Fri, 07 Sep 2007 14:29:49 +0000</pubDate>
		<guid>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-163</guid>
		<description>Good question Matt

You would need to make the extra value(s) you want to use in a Predicate function either module level variables or control values. The way Predicates work you can't pass in additional values on the function call although it would be handy if you could. 

Here's a simple example using a filter value in a text box:

&lt;pre&gt;
Public Function FilterProduct(ByVal product As InventoryItem) As Boolean
    If txtFilter.Text.Length = 0 Then
        Return True
    Else
        If product.Description Like String.Concat("*", txtFilter.Text, "*") Then
            Return True
        Else
            Return False
        End If
    End If
End Function
&lt;/pre&gt;

And a ListBox being populated with the result:

&lt;pre&gt;
With lstSelectedProducts
        .DataSource = Nothing
        .DataSource = ProductList.FindAll(AddressOf FilterProduct)
        .DisplayMember = "Description"
End With
&lt;/pre&gt;

I hope this answers your question. Let me know if it doesn't.</description>
		<content:encoded><![CDATA[<p>Good question Matt</p>
<p>You would need to make the extra value(s) you want to use in a Predicate function either module level variables or control values. The way Predicates work you can&#8217;t pass in additional values on the function call although it would be handy if you could. </p>
<p>Here&#8217;s a simple example using a filter value in a text box:</p>
<pre>
Public Function FilterProduct(ByVal product As InventoryItem) As Boolean
    If txtFilter.Text.Length = 0 Then
        Return True
    Else
        If product.Description Like String.Concat("*", txtFilter.Text, "*") Then
            Return True
        Else
            Return False
        End If
    End If
End Function
</pre>
<p>And a ListBox being populated with the result:</p>
<pre>
With lstSelectedProducts
        .DataSource = Nothing
        .DataSource = ProductList.FindAll(AddressOf FilterProduct)
        .DisplayMember = "Description"
End With
</pre>
<p>I hope this answers your question. Let me know if it doesn&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-155</link>
		<author>Matt</author>
		<pubDate>Fri, 07 Sep 2007 03:21:15 +0000</pubDate>
		<guid>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-155</guid>
		<description>I've been trying to figure out how to use delegates to check for a variable condition.  For example, going back to the original code you used, say I want to only Load products whose .Text is equal to another variable.  I can not figure out how to pass the second variable.

Take Fileter int he example below, for example:

Public Sub LoadProductList(ByVal products As List(Of InventoryItem), byval filter as string)
    lstProducts.Items.Clear()
    For Each item As InventoryItem In products
        If cboProductSubCode.Text.startswith(filter) Then
            lstProducts.Items.Add(item)
        End If
    Next
End Sub</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been trying to figure out how to use delegates to check for a variable condition.  For example, going back to the original code you used, say I want to only Load products whose .Text is equal to another variable.  I can not figure out how to pass the second variable.</p>
<p>Take Fileter int he example below, for example:</p>
<p>Public Sub LoadProductList(ByVal products As List(Of InventoryItem), byval filter as string)<br />
    lstProducts.Items.Clear()<br />
    For Each item As InventoryItem In products<br />
        If cboProductSubCode.Text.startswith(filter) Then<br />
            lstProducts.Items.Add(item)<br />
        End If<br />
    Next<br />
End Sub</p>
]]></content:encoded>
	</item>
</channel>
</rss>
