<?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/"
	>

<channel>
	<title>theDeSilva.com</title>
	<atom:link href="http://www.thedesilva.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedesilva.com</link>
	<description>Andrew de Silva</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:48:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Disable selection on browser using Javascript</title>
		<link>http://www.thedesilva.com/2010/03/disable-selection-on-browser-using-javascript/</link>
		<comments>http://www.thedesilva.com/2010/03/disable-selection-on-browser-using-javascript/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 21:48:23 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[disable select]]></category>
		<category><![CDATA[disable selection]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=199</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/>Here&#8217;s a quick way to disable selection on browsers using Javascript. Helpful if you don&#8217;t want somebody to select a bunch of text and copy and paste.

1
2
3
4
5
6
7
8
9
10
11
12
13
window.onload = function&#40;&#41; &#123;
	disableSelection&#40;document.body&#41;
&#125;
&#160;
function disableSelection&#40;target&#41;&#123;
if &#40;typeof target.onselectstart!=&#34;undefined&#34;&#41; //IE 
	target.onselectstart=function&#40;&#41;&#123;return false&#125;
else if &#40;typeof target.style.MozUserSelect!=&#34;undefined&#34;&#41; //Firefox 
	target.style.MozUserSelect=&#34;none&#34;
else //All other ie: Opera
	target.onmousedown=function&#40;&#41;&#123;return false&#125;
target.style.cursor = &#34;default&#34;
&#125;

]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/><p>Here&#8217;s a quick way to disable selection on browsers using Javascript. Helpful if you don&#8217;t want somebody to select a bunch of text and copy and paste.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	disableSelection<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> disableSelection<span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> target.<span style="color: #660066;">onselectstart</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;undefined&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//IE </span>
	target.<span style="color: #660066;">onselectstart</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> target.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozUserSelect</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;undefined&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">//Firefox </span>
	target.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozUserSelect</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;none&quot;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #006600; font-style: italic;">//All other ie: Opera</span>
	target.<span style="color: #660066;">onmousedown</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span>
target.<span style="color: #660066;">style</span>.<span style="color: #660066;">cursor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;default&quot;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/03/disable-selection-on-browser-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Batch File to Copy Flex Release Build to Production Server</title>
		<link>http://www.thedesilva.com/2010/02/batch-file-to-copy-flex-release-build-to-production-server/</link>
		<comments>http://www.thedesilva.com/2010/02/batch-file-to-copy-flex-release-build-to-production-server/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:19:04 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[batch file]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=194</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flex-icon-small.png" width="32" height="32" alt="" title="Flex" /><br/>Here&#8217;s something that I always do when writing any sort of Flex Application. I&#8217;ll write a batch file that would allow me to quickly double click it and copy all of the files on the bin-release folder to the production server. This normally save me a lot of time as I don&#8217;t have to manually [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flex-icon-small.png" width="32" height="32" alt="" title="Flex" /><br/><p>Here&#8217;s something that I always do when writing any sort of Flex Application. I&#8217;ll write a batch file that would allow me to quickly double click it and copy all of the files on the bin-release folder to the production server. This normally save me a lot of time as I don&#8217;t have to manually look for the files and copy them to the server.</p>
<p>Here&#8217;s a quick way to create the batch file and edit it to do what you want to ,</p>
<ol>
<li> Open up Notepad in Windows. You can do this by navigating to Start &gt; Programs &gt; Accessories &gt; Notepad, or simply by entering notepad under Start &gt; Run.</li>
<li> Save your file before you start writing any code</li>
<li> Go to File &gt; Save As.</li>
<li> Click on the dropdown box &#8220;Save as type:&#8221; and select &#8220;All files&#8221; instead of Text (*.txt).</li>
<li> Add .bat to the end of your file name before you save. For example copy.bat.</li>
<li> Click on Save.</li>
</ol>
<p>Now a little batch commands to delete the files that exist on the production server first before we copy the files from the bin-release folder to the production server followed by opening the page using the default browser.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">REM Delete old production files
del \\production_server_name\production_folder\*.*
REM Copy over <span style="color: #000080;">new</span> production files
copy *.* \\production_server_name\production_folder\
REM <span style="color: #000080;">Open</span> the location of the file using default browser
start www.production_server.com</pre></td></tr></table></div>

<p>The batch file should be located in the same folder as the files that you want to copy</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/02/batch-file-to-copy-flex-release-build-to-production-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using cmd.exe with VB.NET &#8211; Process.Start</title>
		<link>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/</link>
		<comments>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 00:04:14 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[Process.start]]></category>
		<category><![CDATA[system diagnostics]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=190</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>Here&#8217;s a quick function to show the use of System.Diagnostic.Process which will allow you to start another application using VB.NET. The example below is used to call svnadmin to create a new repository ( Subversion ) by grabbing the repository name. The function also checks to see whether the directory exist on the file system [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>Here&#8217;s a quick function to show the use of System.Diagnostic.Process which will allow you to start another application using VB.NET. The example below is used to call svnadmin to create a new repository ( Subversion ) by grabbing the repository name. The function also checks to see whether the directory exist on the file system and if it doesn&#8217;t it will start the command prompt svnadmin to create the folder. However if the folder does exist it will nag at you.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF;">Sub</span> createRepo<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> repoName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> repoNameInput.<span style="color: #0000FF;">Text</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> dirExist <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
&nbsp;
        <span style="color: #0600FF;">If</span> System.<span style="color: #0000FF;">IO</span>.<span style="color: #0600FF;">Directory</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\svn_repository\&quot;</span> <span style="color: #008000;">&amp;</span> repoName<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            dirExist <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
            result.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;font color=&quot;</span><span style="color: #808080;">&quot;red&quot;</span><span style="color: #808080;">&quot;&gt;Repository Already Exist !&lt;/font&gt;&quot;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span>repoName.<span style="color: #0000FF;">Length</span> &lt;&gt; <span style="color: #FF0000;">0</span> <span style="color: #804040;">And</span> dirExist <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            <span style="color: #0600FF;">Dim</span> myProcess <span style="color: #FF8000;">As</span> Process <span style="color: #008000;">=</span> Process.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;cmd.exe&quot;</span>, <span style="color: #808080;">&quot;/k svnadmin create C:\svn_repository\&quot;</span> <span style="color: #008000;">&amp;</span> repoName<span style="color: #000000;">&#41;</span>
&nbsp;
            myProcess.<span style="color: #0000FF;">WaitForExit</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10000</span><span style="color: #000000;">&#41;</span>
            <span style="color: #008080; font-style: italic;">' if the process doesn't complete within</span>
            <span style="color: #008080; font-style: italic;">' 10 seconds, kill it</span>
&nbsp;
            <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> myProcess.<span style="color: #0000FF;">HasExited</span> <span style="color: #FF8000;">Then</span>
                myProcess.<span style="color: #0600FF;">Kill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
            result.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Respository Created: &quot;</span> _
                <span style="color: #008000;">&amp;</span> myProcess.<span style="color: #0000FF;">ExitTime</span> <span style="color: #008000;">&amp;</span> _
                Environment.<span style="color: #0600FF;">NewLine</span> <span style="color: #008000;">&amp;</span> _
                <span style="color: #808080;">&quot;Exit Code (Troubleshooting Purpose): &quot;</span> <span style="color: #008000;">&amp;</span> _
                myProcess.<span style="color: #0000FF;">ExitCode</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

<p>You will have to import the following library to have the Process.Start to work.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Diagnostics</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB.NET Database query return result as XML</title>
		<link>http://www.thedesilva.com/2010/01/vb-net-database-query-return-result-as-xml/</link>
		<comments>http://www.thedesilva.com/2010/01/vb-net-database-query-return-result-as-xml/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 20:00:31 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[data source]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[DataSet]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=186</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>A simple VB.NET page that takes a ID variable and return the result as XML page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
&#160;
Imports System.IO
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient
&#160;
Partial Class writeXML
    Inherits System.Web.UI.Page
&#160;
&#160;
    Protected Sub Page_Load&#40;ByVal sender As Object, ByVal e As System.EventArgs&#41; Handles Me.Load
        GetXML&#40;Request.QueryString&#40;&#34;pid&#34;&#41;&#41;
    End Sub
&#160;
 [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>A simple VB.NET page that takes a ID variable and return the result as XML page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">IO</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Xml</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">SqlClient</span>
&nbsp;
Partial <span style="color: #0600FF;">Class</span> writeXML
    <span style="color: #0600FF;">Inherits</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">Page</span>
&nbsp;
&nbsp;
    Protected <span style="color: #0600FF;">Sub</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Load</span>
        GetXML<span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">QueryString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;pid&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> sqlConnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> SqlConnection
        <span style="color: #0600FF;">Dim</span> oCn <span style="color: #FF8000;">As</span> SqlConnection <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> SqlConnection<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Data Source=xxxx\xxxx; Initial Catalog=tableName; User Id=dbUSERNAME; Password=dbPASSWORD&quot;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Return</span> oCn
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
    <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> GetDataSet<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> strSQL <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> DataSet
&nbsp;
        <span style="color: #008080; font-style: italic;">'1. Create a connection</span>
        <span style="color: #0600FF;">Dim</span> myConnection <span style="color: #FF8000;">As</span> SqlConnection <span style="color: #008000;">=</span> sqlConnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'2. Create the command object, passing in the SQL string    </span>
        <span style="color: #0600FF;">Dim</span> myCommand <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlCommand<span style="color: #000000;">&#40;</span>strSQL, myConnection<span style="color: #000000;">&#41;</span>
&nbsp;
        myConnection.<span style="color: #0600FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'3. Create the DataAdapter</span>
        <span style="color: #0600FF;">Dim</span> myDataAdapter <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlDataAdapter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        myDataAdapter.<span style="color: #0000FF;">SelectCommand</span> <span style="color: #008000;">=</span> myCommand
&nbsp;
&nbsp;
        <span style="color: #008080; font-style: italic;">'4. Populate the DataSet and close the connection</span>
        <span style="color: #0600FF;">Dim</span> myDataSet <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> DataSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        myDataAdapter.<span style="color: #0000FF;">Fill</span><span style="color: #000000;">&#40;</span>myDataSet<span style="color: #000000;">&#41;</span>
        myConnection.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'Return the DataSet</span>
        <span style="color: #FF8000;">Return</span> myDataSet
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> GetXML<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> id <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> sqlCommand <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
&nbsp;
        sqlCommand <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SELECT column1, column2  &quot;</span>
        sqlCommand <span style="color: #008000;">&amp;=</span> <span style="color: #808080;">&quot;FROM tableName &quot;</span>
        sqlCommand <span style="color: #008000;">&amp;=</span> <span style="color: #808080;">&quot;WHERE id = '&quot;</span> <span style="color: #008000;">&amp;</span> id <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;';  &quot;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> retrievedDataSet <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> DataSet
        retrievedDataSet <span style="color: #008000;">=</span> GetDataSet<span style="color: #000000;">&#40;</span>sqlCommand<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> xmlDocument <span style="color: #FF8000;">As</span> XmlDocument <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> XmlDocument
        xmlDocument.<span style="color: #0000FF;">LoadXml</span><span style="color: #000000;">&#40;</span>retrievedDataSet.<span style="color: #0000FF;">GetXml</span><span style="color: #000000;">&#41;</span>
&nbsp;
&nbsp;
        Response.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        Response.<span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;text/xml&quot;</span>
        Response.<span style="color: #0000FF;">ContentEncoding</span> <span style="color: #008000;">=</span> Encoding.<span style="color: #0000FF;">UTF8</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span>xmlDocument.<span style="color: #0000FF;">InnerXml</span><span style="color: #000000;">&#41;</span>
        Response.<span style="color: #0000FF;">Flush</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        Response.<span style="color: #0600FF;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/vb-net-database-query-return-result-as-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greasemonkey &#8211; Add button to page to call function within GreaseMonkey</title>
		<link>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/</link>
		<comments>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 22:14:51 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[onclick]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=180</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/>Here&#8217;s a really quick way to add a button into an existing page and then have the button call a function that is within greasemonkey script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&#160;
window.addEventListener&#40;&#34;load&#34;, function&#40;e&#41; &#123;
  addButton&#40;&#41;;
&#125;, false&#41;;
&#160;
function addButton&#40;&#41;&#123;
 var buttonElems = document.getElementsByTagName&#40;'buttonElementName'&#41;;
 buttonElems&#91;0&#93;.innerHTML = buttonElems&#91;0&#93;.innerHTML + '&#60;input id=&#34;greasemonkeyButton&#34; type=&#34;button&#34; value=&#34;Call Greasemonkey Function&#34; /&#62;'
addButtonListener&#40;&#41;;
&#125;
&#160;
function addButtonListener&#40;&#41;&#123;
  var button = document.getElementById&#40;&#34;greasemonkeyButton&#34;&#41;;
  button.addEventListener&#40;'click',doMonkey,true&#41;;
&#125;
&#160;
function [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/><p>Here&#8217;s a really quick way to add a button into an existing page and then have the button call a function that is within greasemonkey script.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;load&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  addButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> buttonElems <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'buttonElementName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 buttonElems<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> buttonElems<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;input id=&quot;greasemonkeyButton&quot; type=&quot;button&quot; value=&quot;Call Greasemonkey Function&quot; /&gt;'</span>
addButtonListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addButtonListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> button <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;greasemonkeyButton&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  button.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span>doMonkey<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> doMonkey<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//do something</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resize image using VB.NET</title>
		<link>http://www.thedesilva.com/2010/01/resize-image-using-vb-net/</link>
		<comments>http://www.thedesilva.com/2010/01/resize-image-using-vb-net/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 19:35:39 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[image height]]></category>
		<category><![CDATA[image width]]></category>
		<category><![CDATA[resize image]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=178</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>Here&#8217;s a quick function to resize image using VB.NET

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Sub ResizeImage&#40;ByVal dir As String, ByVal fileName As String, ByVal percentResize As Double&#41;
        'following code resizes picture to fit
&#160;
        Dim bm As New Bitmap&#40;&#34;C:\&#34; &#38; dir &#38; &#34;\&#34; &#38; fileName&#41;
&#160;
    [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>Here&#8217;s a quick function to resize image using VB.NET</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Sub</span> ResizeImage<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> <span style="color: #0600FF;">dir</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, <span style="color: #FF8000;">ByVal</span> fileName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, <span style="color: #FF8000;">ByVal</span> percentResize <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Double</span><span style="color: #000000;">&#41;</span>
        <span style="color: #008080; font-style: italic;">'following code resizes picture to fit</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> bm <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Bitmap<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">dir</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> fileName<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> <span style="color: #0600FF;">width</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> bm.<span style="color: #0600FF;">Width</span> <span style="color: #008000;">-</span> <span style="color: #000000;">&#40;</span>bm.<span style="color: #0600FF;">Width</span> <span style="color: #008000;">*</span> percentResize<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">'image width. </span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> height <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> bm.<span style="color: #0000FF;">Height</span> <span style="color: #008000;">-</span> <span style="color: #000000;">&#40;</span>bm.<span style="color: #0000FF;">Height</span> <span style="color: #008000;">*</span> percentResize<span style="color: #000000;">&#41;</span>  <span style="color: #008080; font-style: italic;">'image height</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> thumb <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Bitmap<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">width</span>, height<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> g <span style="color: #FF8000;">As</span> Graphics <span style="color: #008000;">=</span> Graphics.<span style="color: #0000FF;">FromImage</span><span style="color: #000000;">&#40;</span>thumb<span style="color: #000000;">&#41;</span>
&nbsp;
        g.<span style="color: #0000FF;">InterpolationMode</span> <span style="color: #008000;">=</span> Drawing2D.<span style="color: #0000FF;">InterpolationMode</span>.<span style="color: #0000FF;">HighQualityBicubic</span>
&nbsp;
        g.<span style="color: #0000FF;">DrawImage</span><span style="color: #000000;">&#40;</span>bm, <span style="color: #FF8000;">New</span> Rectangle<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #0600FF;">width</span>, height<span style="color: #000000;">&#41;</span>, <span style="color: #FF8000;">New</span> Rectangle<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, bm.<span style="color: #0600FF;">Width</span>, _
bm.<span style="color: #0000FF;">Height</span><span style="color: #000000;">&#41;</span>, GraphicsUnit.<span style="color: #0000FF;">Pixel</span><span style="color: #000000;">&#41;</span>
&nbsp;
        g.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        bm.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'image path.</span>
        thumb.<span style="color: #0000FF;">Save</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">dir</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span> <span style="color: #008000;">&amp;</span> fileName, _
System.<span style="color: #0000FF;">Drawing</span>.<span style="color: #0000FF;">Imaging</span>.<span style="color: #0000FF;">ImageFormat</span>.<span style="color: #0000FF;">Jpeg</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">'can use any image format </span>
&nbsp;
        thumb.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

<p>To use the code all you have to do is to pass in the directory of the image , the file name and the percentage of increase / decrease that you would like. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/resize-image-using-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save File Stream using VB.NET</title>
		<link>http://www.thedesilva.com/2010/01/save-file-stream-using-vb-net/</link>
		<comments>http://www.thedesilva.com/2010/01/save-file-stream-using-vb-net/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 18:14:36 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=165</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>Here is a simple VB.NET that would allow you to post a file stream from Flex.  The class below saves the file into a location on your server. To use it you can simply use HTTP POST and pass in the directory save location using the query string dir. I used a catch try [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>Here is a simple VB.NET that would allow you to post a file stream from Flex.  The class below saves the file into a location on your server. To use it you can simply use HTTP POST and pass in the directory save location using the query string dir. I used a catch try block to log all error since I&#8217;m streaming this and will not see the error. You will find the code to the error logging <a href="http://www.thedesilva.com/2009/08/write-error-log-using-vb-net/">here</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF;">Imports</span> System
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">IO</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Configuration</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Collections</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Security</span>
&nbsp;
&nbsp;
Partial <span style="color: #0600FF;">Class</span> FlexUpload
    <span style="color: #0600FF;">Inherits</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">Page</span>
&nbsp;
    <span style="color: #FF8000;">Private</span> filePath <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
    <span style="color: #FF8000;">Private</span> fileStream <span style="color: #FF8000;">As</span> FileStream
    <span style="color: #FF8000;">Private</span> streamWriter <span style="color: #FF8000;">As</span> StreamWriter
&nbsp;
    Protected <span style="color: #0600FF;">Sub</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Load</span>
        <span style="color: #0600FF;">Dim</span> fileName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
        <span style="color: #0600FF;">Dim</span> <span style="color: #0600FF;">dir</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> Request.<span style="color: #0000FF;">QueryString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;dir&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> saveToFolder <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;C:\&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">dir</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\&quot;</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #008000;">File</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>saveToFolder<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            <span style="color: #008000;">File</span>.<span style="color: #0000FF;">Delete</span><span style="color: #000000;">&#40;</span>saveToFolder<span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Directory</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>saveToFolder<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            <span style="color: #008080; font-style: italic;">' do nothing directory exist</span>
        <span style="color: #FF8000;">Else</span>
            <span style="color: #0600FF;">Directory</span>.<span style="color: #0000FF;">CreateDirectory</span><span style="color: #000000;">&#40;</span>saveToFolder<span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        <span style="color: #0600FF;">Try</span>
            <span style="color: #0600FF;">Dim</span> i <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span>
&nbsp;
            <span style="color: #FF8000;">For</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> Request.<span style="color: #008000;">Files</span>.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span>
                fileName <span style="color: #008000;">=</span> System.<span style="color: #0000FF;">IO</span>.<span style="color: #0000FF;">Path</span>.<span style="color: #0000FF;">GetFileName</span><span style="color: #000000;">&#40;</span>Request.<span style="color: #008000;">Files</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">FileName</span><span style="color: #000000;">&#41;</span>
                Request.<span style="color: #008000;">Files</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SaveAs</span><span style="color: #000000;">&#40;</span>saveToFolder <span style="color: #008000;">&amp;</span> fileName<span style="color: #000000;">&#41;</span>
            <span style="color: #FF8000;">Next</span>
&nbsp;
        <span style="color: #0600FF;">Catch</span> ex <span style="color: #FF8000;">As</span> Exception
            WriteLog<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Error :&quot;</span> <span style="color: #008000;">&amp;</span> DateTime.<span style="color: #0600FF;">Now</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; &quot;</span> <span style="color: #008000;">&amp;</span> ex.<span style="color: #0000FF;">Message</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Try</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">' Error Logging Functions </span>
     <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> OpenFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> strPath <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
        strPath <span style="color: #008000;">=</span> MapPath<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;~&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Error.log&quot;</span>
        <span style="color: #0600FF;">If</span> System.<span style="color: #0000FF;">IO</span>.<span style="color: #008000;">File</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>strPath<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            fileStream <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> FileStream<span style="color: #000000;">&#40;</span>strPath, FileMode.<span style="color: #0000FF;">Append</span>, FileAccess.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Else</span>
            fileStream <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> FileStream<span style="color: #000000;">&#40;</span>strPath, FileMode.<span style="color: #0000FF;">Create</span>, FileAccess.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
        StreamWriter <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> StreamWriter<span style="color: #000000;">&#40;</span>fileStream<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> WriteLog<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> strComments <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
        OpenFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        StreamWriter.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>strComments<span style="color: #000000;">&#41;</span>
        CloseFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> CloseFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        StreamWriter.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        fileStream.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/save-file-stream-using-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embeding Collada files on Flex</title>
		<link>http://www.thedesilva.com/2009/08/embeding-collada-files-on-flex/</link>
		<comments>http://www.thedesilva.com/2009/08/embeding-collada-files-on-flex/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 16:11:49 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[embed collada]]></category>
		<category><![CDATA[mimetype]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=163</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flex-icon-small.png" width="32" height="32" alt="" title="Flex" /><br/>Here&#8217;s how to embed collada files into your Flex.

1
2
3
4
5
6
7
&#160;
&#91;Embed&#40;source=&#34;collada.dae&#34;, mimeType=&#34;application/octet-stream&#34;&#41;&#93;
private var Model3D:Class;
var byteArray:ByteArray = new Model3D&#40;&#41;;
var collada:DAE = new DAE&#40;&#41;;
collada.load&#40;byteArray, material&#41;;
scene.addChild&#40;collada&#41;;

]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flex-icon-small.png" width="32" height="32" alt="" title="Flex" /><br/><p>Here&#8217;s how to embed collada files into your Flex.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">&quot;collada.dae&quot;</span>, mimeType=<span style="color: #ff0000;">&quot;application/octet-stream&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> Model3D:<span style="color: #000000; font-weight: bold;">Class</span>;
<span style="color: #000000; font-weight: bold;">var</span> byteArray:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> Model3D<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> collada:DAE = <span style="color: #000000; font-weight: bold;">new</span> DAE<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
collada.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>byteArray, material<span style="color: #66cc66;">&#41;</span>;
scene.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>collada<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2009/08/embeding-collada-files-on-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write Error Log using VB.NET</title>
		<link>http://www.thedesilva.com/2009/08/write-error-log-using-vb-net/</link>
		<comments>http://www.thedesilva.com/2009/08/write-error-log-using-vb-net/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 21:19:17 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[error log]]></category>
		<category><![CDATA[filestream]]></category>
		<category><![CDATA[streamwriter]]></category>
		<category><![CDATA[vbnet]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=155</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>There are times when you will need to write something to the screen to debug your VB.NET code and find it impossible as there are certain things that doesn&#8217;t really display a page. A web service don&#8217;t normally show a web page after it&#8217;s been called and it&#8217;s such a pain to debug errors if [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>There are times when you will need to write something to the screen to debug your VB.NET code and find it impossible as there are certain things that doesn&#8217;t really display a page. A web service don&#8217;t normally show a web page after it&#8217;s been called and it&#8217;s such a pain to debug errors if you can&#8217;t really see what&#8217;s going wrong. Here&#8217;s a handy way to debug your code, write your error to an error log where you can view the log easily. Here are some code examples.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">    <span style="color: #0600FF;">Imports</span> System
    <span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">IO</span>
    <span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>
&nbsp;
    <span style="color: #FF8000;">Private</span> filePath <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
    <span style="color: #FF8000;">Private</span> fileStream <span style="color: #FF8000;">As</span> FileStream
    <span style="color: #FF8000;">Private</span> streamWriter <span style="color: #FF8000;">As</span> StreamWriter
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> OpenFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> strPath <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
        strPath <span style="color: #008000;">=</span> MapPath<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;~&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;\Error.log&quot;</span>
        <span style="color: #0600FF;">If</span> System.<span style="color: #0000FF;">IO</span>.<span style="color: #008000;">File</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span>strPath<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            fileStream <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> FileStream<span style="color: #000000;">&#40;</span>strPath, FileMode.<span style="color: #0000FF;">Append</span>, FileAccess.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Else</span>
            fileStream <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> FileStream<span style="color: #000000;">&#40;</span>strPath, FileMode.<span style="color: #0000FF;">Create</span>, FileAccess.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
        StreamWriter <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> StreamWriter<span style="color: #000000;">&#40;</span>fileStream<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> WriteLog<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> strComments <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
        OpenFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        StreamWriter.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>strComments<span style="color: #000000;">&#41;</span>
        CloseFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> CloseFile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        StreamWriter.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        fileStream.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

<p>Here&#8217;s how you would use the error log</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;">    <span style="color: #0600FF;">Try</span>
    <span style="color: #008080; font-style: italic;">'Do something</span>
&nbsp;
    <span style="color: #0600FF;">Catch</span> ex <span style="color: #FF8000;">As</span> Exception
        WriteLog<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Error :&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #FF0000;">Date</span>.<span style="color: #0600FF;">Today</span>.<span style="color: #0000FF;">ToString</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; &quot;</span> <span style="color: #008000;">&amp;</span> ex.<span style="color: #0000FF;">Message</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Try</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2009/08/write-error-log-using-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Timers</title>
		<link>http://www.thedesilva.com/2009/08/javascript-timers/</link>
		<comments>http://www.thedesilva.com/2009/08/javascript-timers/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 19:32:06 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[cleartimeout method]]></category>
		<category><![CDATA[javascript timer]]></category>
		<category><![CDATA[setinterval method]]></category>
		<category><![CDATA[settimeout method]]></category>
		<category><![CDATA[timer functions]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=149</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/>JavaScript provides setTimeout(), clearTimeout() , setInterval() and clearInterval() for your javascript timer functions which allows you to run a piece of Javascript code at some point in the future. Here are some explanation of the functions.

setTimeout &#40; expression, timeout &#41;;

setTimeout() returns a numeric timeout ID that can be used to track the timeout. This is [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/><p>JavaScript provides setTimeout(), clearTimeout() , setInterval() and clearInterval() for your javascript timer functions which allows you to run a piece of Javascript code at some point in the future. Here are some explanation of the functions.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">setTimeout <span style="color: #009900;">&#40;</span> expression<span style="color: #339933;">,</span> timeout <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>setTimeout() returns a numeric timeout ID that can be used to track the timeout. This is most commonly used with the clearTimeout() method</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">clearTimeout <span style="color: #009900;">&#40;</span> timeoutId <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// where timeoutId is the ID of the timeout as returned from the setTimeout() method call.</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">setInterval <span style="color: #009900;">&#40;</span> expression<span style="color: #339933;">,</span> interval <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>setInterval() is really close to setTimeout() but setTimeout() only triggers the expression once while setInterval keep triggering the expression over and over.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">clearInterval<span style="color: #009900;">&#40;</span>timeoutId <span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">// where timeoutId is the ID of the timeout as returned from the setInterval() method call.</span></pre></div></div>

<p>clearInterval() is used to cancel a setInterval() when you want to cancel a setInterval() then you need to call clearInterval(), passing in the interval ID returned by the call to setInterval().</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2009/08/javascript-timers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
