<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: How to Use the Action and Predicate Delegates</title>
	<atom:link href="http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/feed/" rel="self" type="application/rss+xml" />
	<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>Wed, 08 Feb 2012 01:07:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Boshmate</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/comment-page-1/#comment-1442</link>
		<dc:creator>Boshmate</dc:creator>
		<pubDate>Thu, 14 Jan 2010 11:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-1442</guid>
		<description>I've beeen looking for a straightforward and to the point explanation of Predicates and this fiited the bill well ( and too I got Actions thrown in for free) . Also, the penny dropped in that these contrstructs are part of the push towards more functional style of programming and resonates strongly with work I've being doing with JQuery .. I kinda like this trend : it can make code more elegant. Anyway thanks for the clear concide article.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve beeen looking for a straightforward and to the point explanation of Predicates and this fiited the bill well ( and too I got Actions thrown in for free) . Also, the penny dropped in that these contrstructs are part of the push towards more functional style of programming and resonates strongly with work I&#8217;ve being doing with JQuery .. I kinda like this trend : it can make code more elegant. Anyway thanks for the clear concide article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: viktor</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/comment-page-1/#comment-1366</link>
		<dc:creator>viktor</dc:creator>
		<pubDate>Tue, 23 Jun 2009 18:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/#comment-1366</guid>
		<description>You can shorten the predicate a bit by saying 

Return item.Description Like (txtItemDescription.Text &amp; "*") 

Instead of:

If item.Description Like (txtItemDescription.Text &amp; "*") Then
        Return True</description>
		<content:encoded><![CDATA[<p>You can shorten the predicate a bit by saying </p>
<p>Return item.Description Like (txtItemDescription.Text &amp; &#8220;*&#8221;) </p>
<p>Instead of:</p>
<p>If item.Description Like (txtItemDescription.Text &amp; &#8220;*&#8221;) Then<br />
        Return True</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Omar</title>
		<link>http://vbnotebookfor.net/2007/08/23/how-to-use-the-action-and-predicate-delegates/comment-page-1/#comment-1018</link>
		<dc:creator>Omar</dc:creator>
		<pubDate>Mon, 10 Mar 2008 13:25:45 +0000</pubDate>
		<guid isPermaLink="false">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-page-1/#comment-164</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 07 Sep 2007 18:13:30 +0000</pubDate>
		<guid isPermaLink="false">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-page-1/#comment-163</link>
		<dc:creator>jfrankcarr</dc:creator>
		<pubDate>Fri, 07 Sep 2007 14:29:49 +0000</pubDate>
		<guid isPermaLink="false">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-page-1/#comment-155</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 07 Sep 2007 03:21:15 +0000</pubDate>
		<guid isPermaLink="false">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>

