<?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>SnippetWare.com &#187; VB.NET</title>
	<atom:link href="http://www.snippetware.com/category/vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snippetware.com</link>
	<description>Code snippets library</description>
	<lastBuildDate>Fri, 22 Jan 2010 12:04:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Enumerate Attributes of an XML Node</title>
		<link>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/</link>
		<comments>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 08:41:49 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=690</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Microsoft&nbsp;</p>
<pre class="brush: vb.net">
&#039; ----------------------------------------
&#039;  Required Imports :
&#039;
&#039;  System.Xml
&#039; ----------------------------------------

For Each attribute As XmlAttribute In node.Attributes

Next
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/enumerate-attributes-of-an-xml-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add an Element to a XML Document</title>
		<link>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/</link>
		<comments>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 08:37:33 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=688</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>Author: Microsoft<br />
Adds a new element to an XML document instance.</p>
<pre class="brush: vb.net">
&#039; ----------------------------------------
&#039;  Required Imports :
&#039;
&#039;  System.Xml
&#039; ----------------------------------------

Dim newElement As XmlNode
newElement = xmlDoc.CreateElement(&quot;Keyword&quot;)
newElement.InnerText = &quot;Value&quot;
xmlDoc.AppendChild(newElement)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/15/add-an-element-to-a-xml-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving Images in Database</title>
		<link>http://www.snippetware.com/2009/10/12/saving-images-in-database/</link>
		<comments>http://www.snippetware.com/2009/10/12/saving-images-in-database/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:24:45 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=654</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/12/saving-images-in-database/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>
<pre class="brush: vb.net">
&#039; Its fairly easy to save a Image in the database using .NET OleDB library, for simplicity I have used MsAccess Database with two Fields,
&#039; FieldName Type
&#039; Pic OLE Object
&#039; FileSize Text
&#039; Author: Manish Mehta
&#039;
&#039;
&#039; FieldName                      Type
&#039; Pic OLE                       Object
&#039; FileSize                       Text

&#039; The following code establishes a database connection and inserts a file in the &quot;Pic&quot; field.
&#039;
&#039; Save the file as SaveImage.vb

Imports System
Imports System.IO
Imports System.Data

Public Class SaveImage
  Shared Sub main()
  &#039;Delaclare a file stream object
  Dim o As System.IO.FileStream
  &#039;Declare a stream reader object
  Dim r As StreamReader
  Dim jpgFile As String
  Console.Write(&quot;Enter a Valid .JPG file path&quot;)
  jpgFile = Console.ReadLine
  If Dir(jpgFile) = &quot;&quot; Then
   Console.Write(&quot;Invalid File Path&quot;)
   Exit Sub
  End If
  &#039;Open the file
  o = New FileStream(jpgFile, FileMode.Open, FileAccess.Read, FileShare.Read)
  &#039;Read the output in a stream reader
  r = New StreamReader(o)
  Try
    &#039;Declare an Byte array to save the content of the file to be saved
    Dim FileByteArray(o.Length - 1) As Byte
    o.Read(FileByteArray, 0, o.Length)
&#039;Open the DataBase Connection, Please map the datasource name to match the &#039;Database path
    Dim Con As New System.Data.OleDb.OleDbConnection(&quot;Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=DbImages.mdb&quot;)
    Dim Sql As String = &quot;INSERT INTO DbImages (Pic,FileSize) VALUES (?,?)&quot;
    &#039;Declare a OleDbCommand Object
    Dim CmdObj As New System.Data.OleDb.OleDbCommand(Sql, Con)
    &#039;Add the parameters
    CmdObj.Parameters.Add(&quot;@Pic&quot;, System.Data.OleDb.OleDbType.Binary, o.Length).Value = FileByteArray
   CmdObj.Parameters.Add(&quot;@FileSize&quot;, System.Data.OleDb.OleDbType.VarChar, 100).Value = o.Length
  Con.Open()
  CmdObj.ExecuteNonQuery()
  Con.Close()
  Catch ex As Exception
    Console.Write(ex.ToString)
  End Try
 End Sub
End Class

&#039; Compile the file as
&#039; vbc SaveImage.vb /r:system.data.dll /r:system.dll
&#039; A file will be inserted in the Database each time we execute SaveImage.exe.
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/12/saving-images-in-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Console Application</title>
		<link>http://www.snippetware.com/2009/10/12/simple-console-application/</link>
		<comments>http://www.snippetware.com/2009/10/12/simple-console-application/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:23:59 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=652</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/12/simple-console-application/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<p>
<pre class="brush: jscript">
Imports system
Imports microsoft.visualbasic &#039; For msgbox

Namespace N1
    Class Ovrl
      Shared Sub main()
        myfunc(&quot;Mansih&quot;)
        myfunc(22)
      End Sub

      &#039;Accepts Integer
      Overloads Shared Function myfunc(ByVal i As Integer) As String
        msgbox(&quot;Overloaded Function Accepting Integer&quot;)
      End Function

     &#039;Accepts String
     Overloads Shared Function myfunc(ByVal s As String) As String
        msgbox(&quot;Overloaded Function Accepting String&quot;)
     End Function
   End Class
End Namespace
</pre>
<p>This Example Demonstrated Function Overloading, It is also possible to overload a Constructor and its also one of my favourite feature.</p>
<pre class="brush: jscript">
Imports system
Imports microsoft.visualbasic &#039; For msgbox

Namespace N1
    Class OvrConst
      Shared Sub main()
        Dim o As New OvrConst()
        Dim x As New OvrConst(&quot;Constructor 2&quot;)
      End Sub

      &#039;cosntructor 1 without parameter
      Public Overloads Sub New()
         msgbox(&quot;Constructor 1&quot;)
      End Sub

      &#039;cosntructor 2 with a String parameter
      Public Overloads Sub New(ByVal s As String)
        msgbox(s)
      End Sub

    End Class
End Namespace
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/12/simple-console-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

