<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Programação em ASP &#187; Sub</title>
	<atom:link href="http://quantodaniel.wordpress.com/tag/sub/feed/" rel="self" type="application/rss+xml" />
	<link>http://quantodaniel.wordpress.com</link>
	<description>Estudando como programar!</description>
	<lastBuildDate>Sun, 02 Aug 2009 06:37:57 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='quantodaniel.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/bfc920e28461661a78837d8e9ef12218?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Programação em ASP &#187; Sub</title>
		<link>http://quantodaniel.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://quantodaniel.wordpress.com/osd.xml" title="Programação em ASP" />
		<item>
		<title>Function ou SUB no ASP?</title>
		<link>http://quantodaniel.wordpress.com/2008/08/23/function-ou-sub-no-asp/</link>
		<comments>http://quantodaniel.wordpress.com/2008/08/23/function-ou-sub-no-asp/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 19:11:14 +0000</pubDate>
		<dc:creator>quantodaniel</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[procedures]]></category>
		<category><![CDATA[Sub]]></category>

		<guid isPermaLink="false">http://quantodaniel.wordpress.com/?p=19</guid>
		<description><![CDATA[Hoje é sábado, já lavei as roupas e fiz o almoço. Agora escrevo um pequeno post para terminar meus trabalhos da faculdade para essa semana.
No post anterior, mostrei como faz uma simples function utilizando ASP, agora, mostro como utilizar uma SUB. Sub tem as mesmas características de uma function, porém, enquanto a function retorna apenas [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quantodaniel.wordpress.com&blog=2059213&post=19&subd=quantodaniel&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hoje é sábado, já lavei as roupas e fiz o almoço. Agora escrevo um pequeno post para terminar meus trabalhos da faculdade para essa semana.</p>
<p>No post anterior, mostrei como faz uma simples <strong>function </strong>utilizando <strong>ASP</strong>, agora, mostro como utilizar uma <strong>SUB</strong>. Sub tem as mesmas características de uma function, porém, enquanto a function retorna apenas um resultado, a sub retorna tudo que estiver com &#8220;<strong>Response.Write</strong>&#8221; dentro dela. Essa é a forma simples de diferenciar as duas opções.</p>
<p>Então, quando utilizar uma <strong>SUB</strong> ou uma <strong>Function</strong>?</p>
<p>Essa resposta fica a critério de cada programador.</p>
<p>Mas Daniel, e você, quando utiliza cada uma delas?</p>
<p>Hum, certo.<br />
Utilizo uma função quando é necessário retornar apenas um valor, como por exemplo: Buscar o nome de um usuário cadastrado em banco, utilizando apenas o ID.</p>
<p>Function RetornaNome(id)</p>
<p>&#8216;Aqui eu faço o select no banco mandando o id do usuario<br />
&#8216;Faço os tratamentos de erro<br />
RetornaNome = &#8216;Aqui eu coloco o nome que trouxe no resultado do select</p>
<p>End Function</p>
<p>Ficaria assim: &#8220;Nome do usuário: &lt;%=RetornaNome%&gt;&#8221;</p>
<p>Utilizo uma <strong>Sub</strong> quando preciso montar algum resultado mais específico, como um <strong>combo</strong>, por exemplo.</p>
<p>Sub MontaCombo()</p>
<p>&#8216;Faço o select no banco de dados buscando o que quero listar na combo<br />
&#8216;Fecho a tag ASP, assim o resultado da sub, será tudo que estiver fora da tag asp. Como um Response.Write.<br />
%&gt;</p>
<p>&lt;select name=&#8221;cbo&#8221;&gt;<br />
&lt;%Aqui faço um loop para listar os dados recebidos no banco%&gt;<br />
&lt;option value=&#8221;&lt;%=Valor ASP%&gt;&#8221;&gt;&lt;%=Valor ASP%&gt;&lt;/option&gt;<br />
&lt;/select&gt;</p>
<p>&lt;%</p>
<p>End Sub</p>
<p>Para chamar, apenas escrevemos: MontaCombo(). Assim listará uma combo diamicamente, posso utilizar para buscar estados ou cidades no banco de dados, sem a necessidade de colocar todos eles diretamente no código <strong>HTML</strong>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quantodaniel.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quantodaniel.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quantodaniel.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quantodaniel.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quantodaniel.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quantodaniel.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quantodaniel.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quantodaniel.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quantodaniel.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quantodaniel.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quantodaniel.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quantodaniel.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quantodaniel.wordpress.com&blog=2059213&post=19&subd=quantodaniel&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://quantodaniel.wordpress.com/2008/08/23/function-ou-sub-no-asp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e1a13a71cc89521c4b6e83f914cbac1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">quantodaniel</media:title>
		</media:content>
	</item>
	</channel>
</rss>