<?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>WiseCodes &#187; VB.NET</title>
	<atom:link href="http://www.wisecodes.com/tag/vbnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wisecodes.com</link>
	<description>Bringing You The Power of Code !!</description>
	<lastBuildDate>Wed, 01 Sep 2010 19:33:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>.NET: Check links (http, https, ftp, news etc &#8230;)</title>
		<link>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/</link>
		<comments>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/#comments</comments>
		<pubDate>Wed, 13 May 2009 18:42:58 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=467</guid>
		<description><![CDATA[In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System. The URI class has property &#8220;Scheme&#8221; that indicates the type of URI scheme today. The schemes that [...]]]></description>
			<content:encoded><![CDATA[<p>In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System.</p>
<p>The URI class has property &#8220;Scheme&#8221; that indicates the type of URI scheme today. The schemes that detects the URI class are:</p>
<p>* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemefile.aspx" target="_blank">UriSchemeFile</a>: tells us that points the direction in which our class is a file URI.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemeftp.aspx" target="_blank">UriSchemeFtp</a>: the scheme is FTP (File Transfer Protocol)<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemegopher.aspx" target="_blank">UriSchemeGopher</a>: specifies that we can access through URI using the Gopher protocol.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemehttp.aspx" target="_blank">UriSchemeHttp</a>: access is a URI using the HTTP protocol.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemehttps.aspx" target="_blank">UriSchemeHttps</a>: the address is https, http secure.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischememailto.aspx" target="_blank">UriSchemeMailto</a>: tells us that the address is an e-mail, which can be accessed via SMTP.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenetpipe.aspx" target="_blank">UriSchemeNetPipe</a>: tells us that the identifier URI is NetPipe.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenettcp.aspx" target="_blank">UriSchemeNetTcp</a>: can access through URI using the protocol NetTCP.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenews.aspx" target="_blank">UriSchemeNews</a>: URI is the address of a newsgroup or News.<br />
* <a href="http://msdn.microsoft.com/en-us/library/system.uri.urischemenntp.aspx" target="_blank">UriSchemeNntp</a>: a newsgroup is accessed via NNTP.</p>
<p>The fields above are just reading.</p>
<p>In the following example, create a constant that contains the address from which we obtain information and identify which type of management is our constant.</p>
<p><strong>In Visual Basic:</strong></p>
<pre class="brush: vb;">
Const strURL As String = “http://www.wisecodes.com”
Dim strDir As New Uri(strURL)
Select Case strDir.Scheme
Case Uri.UriSchemeFile
'Code for when the address is a file
Case Uri.UriSchemeFtp
'Code for when the address is ftp
Case Uri.UriSchemeGopher
'Code for when the address is a file Gopher
Case Uri.UriSchemeHttp
'Code for when the address is http
Case Uri.UriSchemeHttps
'Code for when the address is https
Case Uri.UriSchemeMailto
'Code for when the address is an e-mail
Case Uri.UriSchemeNetPipe
'Code for when the address is NetPipe
Case Uri.UriSchemeNetTcp
'Code for when the address is NetTcp
Case Uri.UriSchemeNews
'Code for when the address is a newsgroup
Case Uri.UriSchemeNntp
'Code for when the address is a newsgroup
'accessible via NNTP.
End Select
</pre>
<p><strong>In C Sharp</strong></p>
<pre class="brush: csharp;">
const string strURL = “http://www.wisecodes.com”
Uri strDir = new Uri (strURL);
switch (strDir.Scheme)
{
case Uri.SchemeFile:
//Code for when the address is a file
case Uri.UriSchemeFtp:
//Code for when the address is ftp
case Uri.UriSchemeGopher:
//Code for when the address is a file Gopher
case Uri.UriSchemeHttp:
//Code for when the address is http
case Uri.UriSchemeHttps:
//Code for when the address is https
case Uri.UriSchemeMailto:
//Code for when the address is an e-mail
case Uri.UriSchemeNetPipe:
//Code for when the address is NetPipe
case Uri.UriSchemeNetTcp:
//Code for when the address is NetTcp
case Uri.UriSchemeNews:
//Code for when the address is a newsgroup
caseUri.UriSchemeNntp:
//Code for when the address is a newsgroup
//accessible via NNTP.
}
</pre>
<p>Link: Via <a href="http://msdn.microsoft.com/en-us/library/system.uri_fields.aspx" target="_blank">Microsoft</a><br />
Happy Programming!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/05/net-check-links-http-https-ftp-news-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading source code of a WebPage</title>
		<link>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/</link>
		<comments>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:36:10 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=376</guid>
		<description><![CDATA[This method, get the HTML source code of any WebPage C#.NET using System.Net; WebClient webClient = new WebClient(); string strHTMLSourceCode = webClient.DownloadString(&#34;http://www.microsoft.com&#34;); VB.NET Imports System.Net Dim webClient As WebClient = New WebClient() Dim strHTMLSourceCode As String = webClient.DownloadString(&#34;http://www.microsoft.com&#34;) Read More about webClient.DownloadString(string)&#8230; Happy Programming!! Share on Facebook]]></description>
			<content:encoded><![CDATA[<p>This method, get the HTML source code of any WebPage</p>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
using System.Net;

WebClient webClient = new WebClient();
string strHTMLSourceCode = webClient.DownloadString(&quot;http://www.microsoft.com&quot;);
</pre>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">
Imports System.Net

Dim webClient As WebClient = New WebClient()
Dim strHTMLSourceCode As String = webClient.DownloadString(&quot;http://www.microsoft.com&quot;)
</pre>
<p>Read More about <a href="http://msdn.microsoft.com/en-us/library/fhd1f0sw(VS.85).aspx" target="_blank">webClient.DownloadString(string)&#8230;</a></p>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/reading-source-code-of-a-webpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net Gridview to CSV, Excel</title>
		<link>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/</link>
		<comments>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:00:57 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=372</guid>
		<description><![CDATA[This method, export to Excel file from Gridview VB.NET Sub wc_gvGridviewToExcel(ByVal gvGridview As Gridview, ByVal strExcelFilePath As String) 'Columns Dim intColumnsCount As Integer = gvGridview.Columns.Count - 1 'Header Dim strHeaderNames As String = Nothing For i = 0 To intColumnsCount strHeaderNames += gvGridview.Columns(i).HeaderText &#38; &#34;;&#34; Next WriteToExcel(strHeaderNames, strExcelFilePath) 'Each Row Dim strRowText As String = [...]]]></description>
			<content:encoded><![CDATA[<p>This method, export to Excel file from Gridview</p>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">

Sub wc_gvGridviewToExcel(ByVal gvGridview As Gridview, ByVal strExcelFilePath As String)

'Columns

Dim intColumnsCount As Integer = gvGridview.Columns.Count - 1

'Header

Dim strHeaderNames As String = Nothing

For i = 0 To intColumnsCount

strHeaderNames += gvGridview.Columns(i).HeaderText &amp; &quot;;&quot;

Next

WriteToExcel(strHeaderNames, strExcelFilePath)

'Each Row

Dim strRowText As String = Nothing

For Each grdRow As gvGridviewRow In gvGridview.Rows

For i = 0 To intColumnsCount

strRowText += grdRow.Cells(i).Text &amp; &quot;;&quot;

Next

WriteToExcel(strRowText, strExcelFilePath)

strRowText = Nothing

Next

End Sub

Sub WriteToExcel(ByVal strText As String, ByVal strExcelFileName As String)

Dim myFileWriter As New System.IO.StreamWriter(strExcelFileName, True)

myFileWriter.WriteLine(strText)

myFileWriter.Close()

End Sub
</pre>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
public void wc_gvGridviewToExcel(Gridview gvGridview, string strExcelFilePath)
{

 //Columns

 int intColumnsCount = gvGridview.Columns.Count - 1;

 //Header

 string strHeaderNames = null;

 for (i = 0; i &lt;= intColumnsCount; i++) {

 strHeaderNames += gvGridview.Columns(i).HeaderText + &quot;;&quot;;
 }

 WriteToExcel(strHeaderNames, strExcelFilePath);

 //Each Row

 string strRowText = null;

 foreach (gvGridviewRow grdRow in gvGridview.Rows) {

 for (i = 0; i &lt;= intColumnsCount; i++) {

 strRowText += grdRow.Cells(i).Text + &quot;;&quot;;
 }

 WriteToExcel(strRowText, strExcelFilePath);

 strRowText = null;

 }
}

public void WriteToExcel(string strText, string strExcelFileName)
{

 System.IO.StreamWriter myFileWriter = new System.IO.StreamWriter(strExcelFileName, true);

 myFileWriter.WriteLine(strText);

 myFileWriter.Close();
}
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/aspnet-gridview-to-csv-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compare Files</title>
		<link>http://www.wisecodes.com/2009/04/compare-files/</link>
		<comments>http://www.wisecodes.com/2009/04/compare-files/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 16:49:40 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=369</guid>
		<description><![CDATA[This method Compares 2 files and returns true or false. C#.NET private bool wc_CompareFiles(string FilePath1, string FilePath2) { FileInfo FI1 = new FileInfo(FilePath1); FileInfo FI2 = new FileInfo(FilePath2); if (FI1.Length != FI2.Length) return false; byte[] Filebytes1 = File.ReadAllBytes(FilePath1); byte[] Filebytes2 = File.ReadAllBytes(FilePath2); if (Filebytes1.Length != Filebytes2.Length) return false; for (int i = 0; i &#38;lt;= [...]]]></description>
			<content:encoded><![CDATA[<p>This method Compares 2 files and returns true or false.</p>
<p><span style="text-decoration: underline;"><strong>C#.NET</strong></span></p>
<pre class="brush: csharp;">
private bool wc_CompareFiles(string FilePath1, string FilePath2)
{
FileInfo FI1 = new FileInfo(FilePath1);
FileInfo FI2 = new FileInfo(FilePath2);

if (FI1.Length != FI2.Length)
return false;

byte[] Filebytes1 = File.ReadAllBytes(FilePath1);
byte[] Filebytes2 = File.ReadAllBytes(FilePath2);

if (Filebytes1.Length != Filebytes2.Length)
return false;

for (int i = 0; i &amp;lt;= Filebytes2.Length - 1; i++)
{
if (Filebytes1[i] != Filebytes2[i])
return false;
}
return true;
}
</pre>
<p><span style="text-decoration: underline;"><strong>VB.NET</strong></span></p>
<pre class="brush: vb;">

Private Function wc_CompareFiles(ByVal FilePath1 As String, ByVal FilePath2 As String) As Boolean
 Dim FI1 As New FileInfo(FilePath1)
 Dim FI2 As New FileInfo(FilePath2)

 If FI1.Length &lt;&gt; FI2.Length Then
 Return False
 End If

 Dim Filebytes1 As Byte() = File.ReadAllBytes(FilePath1)
 Dim Filebytes2 As Byte() = File.ReadAllBytes(FilePath2)

 If Filebytes1.Length &lt;&gt; Filebytes2.Length Then
 Return False
 End If

 For i As Integer = 0 To Filebytes2.Length - 1
 If Filebytes1(i) &lt;&gt; Filebytes2(i) Then
 Return False
 End If
 Next
 Return True
End Function
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/compare-files/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/compare-files/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/compare-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET: Color Balance</title>
		<link>http://www.wisecodes.com/2009/04/net-color-balance/</link>
		<comments>http://www.wisecodes.com/2009/04/net-color-balance/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 18:21:18 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=300</guid>
		<description><![CDATA[Represents a good control horizontal scroll bar of Windows standard, this screen will see how to change the colors to a panel control by controlling HScrollBar. Public Class Form1_WiseCodes Private Sub Red_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Red_HScrollBar.ValueChanged ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value)) lblRedValue.Text = Red_HScrollBar.Value [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wisecodes.com/wp-content/uploads/2009/04/colorbalance_02.jpg"></a>Represents a good control horizontal scroll bar of Windows standard, this screen will see how to change the colors to a panel control by controlling HScrollBar.</p>
<p><a href="http://www.wisecodes.com/wp-content/uploads/2009/04/colorbalance.jpg" target="_blank"><img class="alignnone size-full wp-image-302" title="colorbalance" src="http://www.wisecodes.com/wp-content/uploads/2009/04/colorbalance.jpg" alt="colorbalance" width="457" height="240" /></a></p>
<pre class="brush: vb;">
Public Class Form1_WiseCodes

 Private Sub Red_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Red_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblRedValue.Text = Red_HScrollBar.Value
 End Sub

 Private Sub Green_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Green_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblGreenValue.Text = Green_HScrollBar.Value
 End Sub

 Private Sub Blue_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Blue_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblBlueValue.Text = Blue_HScrollBar.Value
 End Sub

End Class
</pre>
<p>Set Values of all the HScrollBar as following . The three arguments (red, green &amp; blue)  must <em><span style="font-style: normal;">each</span></em> be in the range 0 to 255.</p>
<p><a href="http://www.wisecodes.com/wp-content/uploads/2009/04/colorbalance_02.jpg"><img class="alignnone size-full wp-image-307" title="colorbalance_02" src="http://www.wisecodes.com/wp-content/uploads/2009/04/colorbalance_02.jpg" alt="colorbalance_02" width="298" height="396" /></a></p>
<h3><a href="http://www.wisecodes.com/Code/ColorBalance/ColorBalance.zip" target="_blank">Download Source Code</a></h3>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/net-color-balance/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/net-color-balance/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/net-color-balance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTP file upload in .NET 2.0</title>
		<link>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/</link>
		<comments>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 20:34:20 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[.NET 3.0]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[.NET 2.0]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=317</guid>
		<description><![CDATA[It is clear that the FileUpload components, which can be found on the Standard toolbar of Visual Studio 2005 allows uploading files to the remote site, but does not cover all the expectations desired or at least not mine. So it is interesting to know how we can attack a specific server and an FTP [...]]]></description>
			<content:encoded><![CDATA[<p>It is clear that the FileUpload components, which can be found on the Standard toolbar of Visual Studio 2005 allows uploading files to the remote site, but does not cover all the expectations desired or at least not mine.<br />
So it is interesting to know how we can attack a specific server and an FTP to copy the desired file to the remote location to stay.</p>
<p>To do this:</p>
<p><strong>Step 1: </strong>In general declarations establish that the class will use.</p>
<p><strong>C#</strong></p>
<pre class="brush: csharp;">
using System.Net;
</pre>
<p><strong>VB.NET</strong></p>
<pre class="brush: vb;">
Imports System.Net
</pre>
<p><strong>Step 2:</strong> Create a button in the Click event and write the following code in C# or VB.NET:</p>
<p><strong>C#</strong></p>
<pre class="brush: csharp;">
private static void wc_UploadFTP(string ftpServerPath, string filename, string username, string password)
 {
WebClient ClientFtp = new WebClient() ;
ClientFtp.Credentials = new NetworkCredential(username, password);
ClientFtp.UploadFile(ftpServerPath + &quot;/&quot; + new FileInfo(filename).Name, &quot;STOR&quot;, filename);
}
</pre>
<p><strong>VB.NET</strong></p>
<pre class="brush: vb;">

Private Shared Sub wc_UploadFTP(ByVal ftpServerPath As String, ByVal filename As String, ByVal username As String, ByVal password As String)
 Dim ClientFtp As New WebClient()
 ClientFtp.Credentials = New NetworkCredential(username, password)
 ClientFtp.UploadFile((ftpServerPath &amp; &quot;/&quot;) + New FileInfo(filename).Name, &quot;STOR&quot;, filename)
End Sub
</pre>
</pre>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/ftp-file-upload-in-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Drop Down List Options From Enum</title>
		<link>http://www.wisecodes.com/2009/04/create-drop-down-list-options-from-enum/</link>
		<comments>http://www.wisecodes.com/2009/04/create-drop-down-list-options-from-enum/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 20:14:09 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Enum]]></category>
		<category><![CDATA[Learn]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.code.venuthomas.net/?p=275</guid>
		<description><![CDATA[To view the values of an enumeration&#8217;s type (enum) to a DropdownList (or other controls with a DataSource property available) is sufficient to bind the following code: Here&#8217;s an example with its own enum (of course also works with system types) ?View Code CSHARPpublic enum CountryList &#123; Germany = 1, India = 2, Japan = [...]]]></description>
			<content:encoded><![CDATA[<p>To view the values of an enumeration&#8217;s type (<a href="http://msdn.microsoft.com/en-us/library/system.enum.aspx" target="_blank">enum</a>) to a DropdownList (or other controls with a DataSource property available) is sufficient to bind the following code:</p>
<p>Here&#8217;s an example with its own <a href="http://msdn.microsoft.com/en-us/library/system.enum.aspx" target="_blank">enum</a> (of course also works with system types)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p275code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2753"><td class="code" id="p275code3"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">enum</span> CountryList
<span style="color: #008000;">&#123;</span>
Germany <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>,
India <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>,
Japan <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>,
UAE <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>,
USA <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
DropdownList1<span style="color: #008000;">.</span><span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Enum</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetValues</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>CountryList<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Now, whenever you want to get to The Value of Even enum () method of the enum is useful to get under the VALUE of enum sees below snippet will helpful to<br />
you.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p275code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2754"><td class="code" id="p275code4"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> intCountry <span style="color: #008000;">=</span> Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">ToInt32</span><span style="color: #008000;">&#40;</span><span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Enum</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span>CountryList<span style="color: #008000;">&#41;</span>, DropdownList1<span style="color: #008000;">.</span><span style="color: #0000FF;">SelectedItem</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p><a href="http://msdn.microsoft.com/en-us/library/system.enum.aspx" target="_blank">Read More&#8230;</a></p>
<p>Happy Programming!!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/create-drop-down-list-options-from-enum/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/04/create-drop-down-list-options-from-enum/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/04/create-drop-down-list-options-from-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate: Username, Email Id, Phone No, Zip Code &amp; URL In 5 Languages(JS, C#.Net, VB.Net, JAVA &amp; PHP)</title>
		<link>http://www.wisecodes.com/2009/03/validate-username-email-id-phone-no-zip-code-url-in-5-languages/</link>
		<comments>http://www.wisecodes.com/2009/03/validate-username-email-id-phone-no-zip-code-url-in-5-languages/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 14:23:09 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Learn]]></category>

		<guid isPermaLink="false">http://www.code.venuthomas.net/?p=225</guid>
		<description><![CDATA[Validate of Username, Email Id, Phone No, Zip/Postal Code &#38; URL In Javascript, C#.Net, VB.Net, JAVA &#38; PHP ! 1. Validate username: Validate alpha numeric values 2. Validate email addresses : example@domain.com 3. Validate Phone numbers: Validate US phone number eg: 123-456-7890 4. Validate Zip/Postal Codes: Validate US Zip/Postal Code eg: 12345-6789 5. Validate Domain [...]]]></description>
			<content:encoded><![CDATA[<p>Validate of Username, Email Id, Phone No, Zip/Postal Code &amp; URL In Javascript, C#.Net, VB.Net, JAVA &amp; PHP !</p>
<p>1. Validate username: Validate alpha numeric values<br />
2. Validate email addresses : example@domain.com<br />
3. Validate Phone numbers: Validate US phone number eg: 123-456-7890<br />
4. Validate Zip/Postal Codes: Validate US Zip/Postal Code eg: 12345-6789<br />
5. Validate Domain Name eg: http://live.com</p>
<h2>Validate username: Validate alpha numeric values </h2>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code30'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22530"><td class="code" id="p225code30"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> is_valid_username<span style="color: #009900;">&#40;</span>str_username<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> filter <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^([a-zA-Z\s0-9]*)$/</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filter.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str_username<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>’Wrong username format.’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Username format is ok.'</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code31'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22531"><td class="code" id="p225code31"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> is_valid_username<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> str_username<span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Regex matchRegex <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;^[a-zA-Z0-9_]{3,16}$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 MatchCollection matches  <span style="color: #008000;">=</span> matchRegex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>str_username<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>matches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">==</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wrong username format.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Wrong username format.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #0600FF; font-weight: bold;">else</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Username format is ok.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Username format is ok.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code32'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22532"><td class="code" id="p225code32"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> is_valid_username<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> str_username <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matchRegex <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Regex<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;^[a-zA-Z0-9_]{3,16}$&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matches <span style="color: #FF8000;">As</span> MatchCollection <span style="color: #008000;">=</span> matchRegex.<span style="color: #0000FF;">Matches</span><span style="color: #000000;">&#40;</span>str_username<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> matches.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wrong username format.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Wrong username format.&quot;); 'In Windows Form</span>
    <span style="color: #FF8000;">Else</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Username format is ok.&quot;</span><span style="color: #000000;">&#41;</span>    <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Username format is ok.&quot;); 'In Windows Form</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code33'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22533"><td class="code" id="p225code33"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> is_valid_username
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str_username<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 Pattern p<span style="color: #339933;">=</span>Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^[A-Za-z0-9]+$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Matcher m<span style="color: #339933;">=</span>p.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>str_username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">boolean</span> matchFound <span style="color: #339933;">=</span> m.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>matchFound<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username format is ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong username format.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code34'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22534"><td class="code" id="p225code34"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> is_valid_username<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str_username</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[a-z\d_]{5,20}$/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str_username</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Username format is ok.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Wrong username format.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Validate email addresses : example@domain.com </h2>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code35'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22535"><td class="code" id="p225code35"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> is_valid_email<span style="color: #009900;">&#40;</span>str_email_id<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> filter <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filter.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str_email_id<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>’Wrong email address format.’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Email address format is ok.'</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code36'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22536"><td class="code" id="p225code36"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> is_valid_email<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> email_id<span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Regex matchRegex <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 MatchCollection matches  <span style="color: #008000;">=</span> matchRegex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>email_id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>matches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">==</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wrong email address format.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Wrong email address format.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #0600FF; font-weight: bold;">else</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Email address format is ok.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Email address format is ok.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code37'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22537"><td class="code" id="p225code37"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> is_valid_email<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> email_id <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matchRegex <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Regex<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matches <span style="color: #FF8000;">As</span> MatchCollection <span style="color: #008000;">=</span> matchRegex.<span style="color: #0000FF;">Matches</span><span style="color: #000000;">&#40;</span>email_id<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> matches.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wrong email address format.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Wrong email address format.&quot;); 'In Windows Form</span>
    <span style="color: #FF8000;">Else</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Email address format is ok.&quot;</span><span style="color: #000000;">&#41;</span>    <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Email address format is ok.&quot;); 'In Windows Form</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code38'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22538"><td class="code" id="p225code38"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> is_valid_email
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str_email_id<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 Pattern p<span style="color: #339933;">=</span>Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[a-zA-Z]*[0-9]*@[a-zA-Z]*.[a-zA-Z]*&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Matcher m<span style="color: #339933;">=</span>p.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>str_email_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">boolean</span> matchFound <span style="color: #339933;">=</span> m.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>matchFound<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Email address format is ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong email address format.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code39'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22539"><td class="code" id="p225code39"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> is_valid_email<span style="color: #009900;">&#40;</span><span style="color: #000088;">$email_id</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$email_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Email address format is ok.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Wrong email address format.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2><strong>Validate Phone numbers: Validate US phone number eg: 123-456-7890</strong></h2>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code40'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22540"><td class="code" id="p225code40"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> is_valid_phone_no<span style="color: #009900;">&#40;</span>str_phone_no<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> filter <span style="color: #339933;">=</span>  <span style="color: #009966; font-style: italic;">/^((\+?1-)?\d\d\d-)?\d\d\d-\d\d\d\d$/</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filter.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str_phone_no<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>’Wrong phone number format.’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Phone number format is ok.'</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code41'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22541"><td class="code" id="p225code41"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> is_valid_phone_no<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> str_phone_no<span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Regex matchRegex <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;\d{3}-\d{3}-\d{4}$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 MatchCollection matches  <span style="color: #008000;">=</span> matchRegex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>str_phone_no<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>matches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">==</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wrong phone number format.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Wrong phone number format.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #0600FF; font-weight: bold;">else</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Phone number format is ok.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Phone number format is ok.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code42'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22542"><td class="code" id="p225code42"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span>
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> is_valid_phone_no<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> str_phone_no <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matchRegex <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Regex<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;\d{3}-\d{3}-\d{4}$&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matches <span style="color: #FF8000;">As</span> MatchCollection <span style="color: #008000;">=</span> matchRegex.<span style="color: #0000FF;">Matches</span><span style="color: #000000;">&#40;</span>str_phone_no<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> matches.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wrong phone number format.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Wrong phone number format.&quot;); 'In Windows Form</span>
    <span style="color: #FF8000;">Else</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Phone number format is ok.&quot;</span><span style="color: #000000;">&#41;</span>    <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Phone number format is ok.&quot;); 'In Windows Form</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code43'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22543"><td class="code" id="p225code43"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> is_valid_phone_no
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str_phone_no<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 Pattern p<span style="color: #339933;">=</span>Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^<span style="color: #000099; font-weight: bold;">\\</span>(?(<span style="color: #000099; font-weight: bold;">\\</span>d{3})<span style="color: #000099; font-weight: bold;">\\</span>)?[- ]?(<span style="color: #000099; font-weight: bold;">\\</span>d{3})[- ]?(<span style="color: #000099; font-weight: bold;">\\</span>d{4})$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Matcher m<span style="color: #339933;">=</span>p.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>str_phone_no<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">boolean</span> matchFound <span style="color: #339933;">=</span> m.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>matchFound<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Phone number format is ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong phone number format.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code44'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22544"><td class="code" id="p225code44"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> is_valid_phone_no<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str_phone_no</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str_phone_no</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Phone number format is ok.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Wrong phone number format.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Validate Zip/Postal Codes: Validate US Zip/Postal Code eg: 12345-6789</h2>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code45'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22545"><td class="code" id="p225code45"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> is_valid_zip_code<span style="color: #009900;">&#40;</span>str_zip_code<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> filter <span style="color: #339933;">=</span>  <span style="color: #009966; font-style: italic;">/^\d\d\d\d\d-\d\d\d\d$/</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filter.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str_zip_code<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>’Wrong Zip<span style="color: #339933;">/</span>Postal Code format.’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Zip/Postal Code format is ok.'</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code46'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22546"><td class="code" id="p225code46"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> is_valid_zip_code<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> str_zip_code<span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Regex matchRegex <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;\d{5}-\d{4}$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 MatchCollection matches  <span style="color: #008000;">=</span> matchRegex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>str_zip_code<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>matches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">==</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wrong Zip/Postal Code format.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Wrong Zip/Postal Code format.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #0600FF; font-weight: bold;">else</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Zip/Postal Code format is ok.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Zip/Postal Code format is ok.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code47'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22547"><td class="code" id="p225code47"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span>
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> is_valid_zip_code<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> str_zip_code <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matchRegex <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Regex<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;\d{5}-\d{4}$&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matches <span style="color: #FF8000;">As</span> MatchCollection <span style="color: #008000;">=</span> matchRegex.<span style="color: #0000FF;">Matches</span><span style="color: #000000;">&#40;</span>str_zip_code<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> matches.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wrong Zip/Postal Code format.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Wrong Zip/Postal Code format.&quot;); 'In Windows Form</span>
    <span style="color: #FF8000;">Else</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Zip/Postal Code format is ok.&quot;</span><span style="color: #000000;">&#41;</span>    <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Zip/Postal Code format is ok.&quot;); 'In Windows Form</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code48'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22548"><td class="code" id="p225code48"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> is_valid_zip_code
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str_zip_code<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 Pattern p<span style="color: #339933;">=</span>Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^(<span style="color: #000099; font-weight: bold;">\\</span>d{5})[- ]?(<span style="color: #000099; font-weight: bold;">\\</span>d{4})$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Matcher m<span style="color: #339933;">=</span>p.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>str_zip_code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">boolean</span> matchFound <span style="color: #339933;">=</span> m.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>matchFound<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Zip/Postal Code format is ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong Zip/Postal Code format.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code49'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22549"><td class="code" id="p225code49"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> is_valid_zip_code<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str_zip_code</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^([0-9]{5})(-[0-9]{4})?$/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str_zip_code</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Zip/Postal Code format is ok.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Wrong Zip/Postal Code format.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Validate  Domain Name eg: http://live.com</h2>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code50'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22550"><td class="code" id="p225code50"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> is_valid_url<span style="color: #009900;">&#40;</span>str_url<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> filter <span style="color: #339933;">=</span>   <span style="color: #009966; font-style: italic;">/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s&amp;lt;&amp;gt;\#%&quot;\,\{\}\\|\\\^\[\]`]+)?$/</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>filter.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>str_url<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>’Wrong URL format.’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'URL format is ok.'</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code51'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22551"><td class="code" id="p225code51"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text.RegularExpressions</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> is_valid_url<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> str_url<span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
Regex matchRegex <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;amp;=]*)?&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 MatchCollection matches  <span style="color: #008000;">=</span> matchRegex<span style="color: #008000;">.</span><span style="color: #0000FF;">Matches</span><span style="color: #008000;">&#40;</span>str_url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>matches<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">==</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wrong URL format.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;Wrong URL format.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #0600FF; font-weight: bold;">else</span>
 <span style="color: #008000;">&#123;</span>
 Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;URL format is ok.&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// In Webserver</span>
 <span style="color: #008080; font-style: italic;">//MessageBox.Show(&quot;URL format is ok.&quot;); //In Windows Form</span>
 <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code52'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22552"><td class="code" id="p225code52"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span>
&nbsp;
<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> is_valid_url<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> str_url <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matchRegex <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Regex<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;amp;=]*)?&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">Dim</span> matches <span style="color: #FF8000;">As</span> MatchCollection <span style="color: #008000;">=</span> matchRegex.<span style="color: #0000FF;">Matches</span><span style="color: #000000;">&#40;</span>str_url<span style="color: #000000;">&#41;</span>
    <span style="color: #0600FF;">If</span> matches.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Wrong URL format.&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;Wrong URL format.&quot;); 'In Windows Form</span>
    <span style="color: #FF8000;">Else</span>
        Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;URL format is ok.&quot;</span><span style="color: #000000;">&#41;</span>    <span style="color: #008080; font-style: italic;">' In Webserver</span>
        <span style="color: #008080; font-style: italic;">'MessageBox.Show(&quot;URL format is ok.&quot;); 'In Windows Form</span>
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code53'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22553"><td class="code" id="p225code53"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> is_valid_url
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str_url<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 Pattern p<span style="color: #339933;">=</span>Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(http|https)://([<span style="color: #000099; font-weight: bold;">\w</span>-]+<span style="color: #000099; font-weight: bold;">\.</span>)+[<span style="color: #000099; font-weight: bold;">\w</span>-]+(/[<span style="color: #000099; font-weight: bold;">\w</span>- ./?%&amp;amp;=]*)?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 Matcher m<span style="color: #339933;">=</span>p.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>str_url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">boolean</span> matchFound <span style="color: #339933;">=</span> m.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>matchFound<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;URL format is ok.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">else</span>
 <span style="color: #009900;">&#123;</span>
 <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Wrong URL format.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p225code54'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p22554"><td class="code" id="p225code54"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">Function</span> is_valid_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str_url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^([0-9]{5})(-[0-9]{4})?$/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str_url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;URL format is ok.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">else</span>
 <span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Wrong URL format.&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/03/validate-username-email-id-phone-no-zip-code-url-in-5-languages/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/03/validate-username-email-id-phone-no-zip-code-url-in-5-languages/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/03/validate-username-email-id-phone-no-zip-code-url-in-5-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# From VB.NET</title>
		<link>http://www.wisecodes.com/2009/03/c-from-vbnet/</link>
		<comments>http://www.wisecodes.com/2009/03/c-from-vbnet/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 15:34:56 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Difference]]></category>
		<category><![CDATA[Learn]]></category>

		<guid isPermaLink="false">http://www.code.venuthomas.net/?p=137</guid>
		<description><![CDATA[What is dfferent between C#.NET &#038; VB.NET Basic differences C # will be marked in the case identifiers and method names and class names, VB does not distinguish. VB is switched to late binding and early binding (Option Strict On / Off). VB is whether to switch to force a variable&#8217;s type (Option Explicit On [...]]]></description>
			<content:encoded><![CDATA[<p>What is dfferent between C#.NET &#038; VB.NET</p>
<h4>Basic differences</h4>
<ul>
<li>C # will be marked in the case identifiers and method names and class names, VB does not distinguish.</li>
<li>VB is switched to late binding and early binding (Option Strict On / Off).</li>
<li>VB is whether to switch to force a variable&#8217;s type (Option Explicit On / Off).</li>
</ul>
<h4>Literals</h4>
<p>Not easily accomplished</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code86'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13786"><td class="code" id="p137code86"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #6666cc; font-weight: bold;">string</span> s <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Welcome&quot;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">char</span> ch <span style="color: #008000;">=</span> <span style="color: #666666;">'abc'</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">123</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">long</span> l <span style="color: #008000;">=</span> 123L<span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">double</span> d <span style="color: #008000;">=</span> <span style="color: #FF0000;">123.0</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">float</span> f <span style="color: #008000;">=</span> 123<span style="color: #008000;">.</span>0F<span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">bool</span> bl <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">object</span> o <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code87'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13787"><td class="code" id="p137code87"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> s <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Welcome&quot;</span>
<span style="color: #0600FF;">Dim</span> ch <span style="color: #FF8000;">As</span> Char <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;abc&quot;</span> c
<span style="color: #0600FF;">Dim</span> i <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">123</span>
<span style="color: #0600FF;">Dim</span> l <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Long</span> <span style="color: #008000;">=</span> 123L
<span style="color: #0600FF;">Dim</span> d <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Double</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">123.0</span>
<span style="color: #0600FF;">Dim</span> f <span style="color: #FF8000;">As</span> Single <span style="color: #008000;">=</span> <span style="color: #FF0000;">123.0</span> F
<span style="color: #0600FF;">Dim</span> bl <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
<span style="color: #0600FF;">Dim</span> o <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span></pre></td></tr></table></div>

<p>Date Literals</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code88'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13788"><td class="code" id="p137code88"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> d1 <span style="color: #008000;">=</span> # 05 <span style="color: #008000;">/</span> 01 <span style="color: #008000;">/</span> <span style="color: #FF0000;">2008</span> #
<span style="color: #0600FF;">Dim</span> d2 <span style="color: #008000;">=</span> # 05 <span style="color: #008000;">/</span> 01 <span style="color: #008000;">/</span> <span style="color: #FF0000;">2008</span> <span style="color: #FF0000;">12</span>: 00: 00 AM #</pre></td></tr></table></div>

<p>I have another spare.</p>
<h4>Array</h4>
<p>Creation and access of the array</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code89'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13789"><td class="code" id="p137code89"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> array <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">int</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Skip
<span style="color: #6666cc; font-weight: bold;">int</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> array <span style="color: #008000;">=</span> <span style="color: #008000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Type inference
var array <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">int</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span> <span style="color: #008000;">&#40;</span>array <span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span> <span style="color: #008000;">&#40;</span>array <span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span> <span style="color: #008000;">&#40;</span>array <span style="color: #008000;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code90'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13790"><td class="code" id="p137code90"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> <span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">new</span> <span style="color: #FF0000;">Integer</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#125;</span>
<span style="color: #008080; font-style: italic;">'Omitted</span>
<span style="color: #0600FF;">Dim</span> <span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #000000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#125;</span>
<span style="color: #008080; font-style: italic;">'Type inference</span>
<span style="color: #0600FF;">Dim</span> <span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> <span style="color: #FF0000;">Integer</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">8</span>, <span style="color: #FF0000;">9</span>, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#125;</span>
&nbsp;
Console. <span style="color: #0000FF;">WriteLine</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
Console. <span style="color: #0000FF;">WriteLine</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
Console. <span style="color: #0000FF;">WriteLine</span> <span style="color: #000000;">&#40;</span><span style="color: #0600FF;">array</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

<h4>Operator</h4>
<p>The difference is in this together as<br />
<b>Equal Sign: </b><br />
C# : ==<br />
VB.NET  =<br />
<b>Inequality:</b><br />
C# :     !=<br />
VB.NET: <></p>
<h4>Statement</h4>
<p>Conditional or repetitive statement</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code91'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13791"><td class="code" id="p137code91"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> int_val <span style="color: #008000;">=</span> Get_Value <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Conditional branch
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>int_val <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">True</span>
<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">Else</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">False</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">For</span> statement
<span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span><span style="color: #FF0000;">10</span><span style="color: #008000;">;</span> i <span style="color: #008000;">+</span> <span style="color: #008000;">+</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Processing
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #6666cc; font-weight: bold;">int</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> int_Array <span style="color: #008000;">=</span> Get_Array <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Statement <span style="color: #008000;">&#40;</span>Collection<span style="color: #008000;">&#41;</span>
<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #0600FF; font-weight: bold;">in</span> int_Array<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Processing
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code92'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13792"><td class="code" id="p137code92"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> int_val <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> Get_Value <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">'Branches</span>
<span style="color: #0600FF;">If</span> int_val <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
<span style="color: #008080; font-style: italic;">'True</span>
<span style="color: #FF8000;">Else</span>
<span style="color: #008080; font-style: italic;">'False</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Statement</span>
<span style="color: #FF8000;">For</span> i <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">to</span> <span style="color: #FF0000;">10</span>
<span style="color: #008080; font-style: italic;">'Treatment</span>
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">For</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> int_Array <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #000000;">&#40;</span>,<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Get_Array <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-style: italic;">'Statement (Collection)</span>
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> i <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> in int_Array
<span style="color: #008080; font-style: italic;">'Treatment</span>
<span style="color: #FF8000;">Next</span></pre></td></tr></table></div>

<h4>Namespace</h4>
<p>Namespace</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code93'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13793"><td class="code" id="p137code93"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> TheCodersSpace <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Define
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Import
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">TheCodersSpace</span><span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Alias
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">TC </span><span style="color: #008000;">=</span> TheCodersSpace<span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code94'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13794"><td class="code" id="p137code94"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Namespace</span> TheCodersSpace
<span style="color: #008080; font-style: italic;">'Definition</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Namespace</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Import</span>
<span style="color: #0600FF;">Imports</span> TheCodersSpace
<span style="color: #008080; font-style: italic;">'Alias</span>
<span style="color: #0600FF;">Imports</span> TC <span style="color: #008000;">=</span> TheCodersSpace</pre></td></tr></table></div>

<p>Import XML namespace</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code95'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13795"><td class="code" id="p137code95"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> &lt;xmlns:TheCoders<span style="color: #008000;">=</span><span style="color: #808080;">&quot;http://code.venuthomas.net&quot;</span>&gt;</pre></td></tr></table></div>

<p><strong>Class</strong></p>
<p>Class (VB, the class also included in the module)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code96'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13796"><td class="code" id="p137code96"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">class</span> TheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">Static</span> <span style="color: #6666cc; font-weight: bold;">class</span>
<span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> StaticTheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Abstract <span style="color: #0600FF; font-weight: bold;">base</span> <span style="color: #6666cc; font-weight: bold;">class</span>
abstract <span style="color: #6666cc; font-weight: bold;">class</span> AbstractTheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Inheritance
<span style="color: #6666cc; font-weight: bold;">class</span> ExtendTheCoders<span style="color: #008000;">:</span> TheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> No inheritance
<span style="color: #0600FF; font-weight: bold;">sealed</span> <span style="color: #6666cc; font-weight: bold;">class</span> SealedTheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code97'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13797"><td class="code" id="p137code97"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Class</span> TheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Static class (Module)</span>
Module StaticTheCoders
<span style="color: #0600FF;">End</span> Module
&nbsp;
<span style="color: #008080; font-style: italic;">'Base class</span>
<span style="color: #FF8000;">MustInherit</span> <span style="color: #0600FF;">Class</span> AbstractTheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Inherited</span>
<span style="color: #0600FF;">Class</span> ExtendTheCoders
<span style="color: #0600FF;">Inherits</span> TheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Not Inherited</span>
<span style="color: #FF8000;">NotInheritable</span> <span style="color: #0600FF;">Class</span> SealedTheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

<h4>Interface</h4>
<p>Interface</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code98'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13798"><td class="code" id="p137code98"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">interface</span> ITheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Implementation
<span style="color: #6666cc; font-weight: bold;">class</span> TheCoders<span style="color: #008000;">:</span> ITheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code99'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13799"><td class="code" id="p137code99"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Interface</span> ITheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Interface</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Implementation</span>
<span style="color: #0600FF;">Class</span> TheCoders
<span style="color: #0600FF;">Implements</span> ITheCoders
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

<h4>Structure</h4>
<p>Structure</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code100'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137100"><td class="code" id="p137code100"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">struct</span> TheCoders <span style="color: #008000;">&#123;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code101'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137101"><td class="code" id="p137code101"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Structure</span> TheCoders
<span style="color: #FF8000;">Public</span> Name <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Structure</span></pre></td></tr></table></div>

<h4>Methods</h4>
<p>Method (professional function)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code102'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137102"><td class="code" id="p137code102"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersDoSomething <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">In</span> argument
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersPrintMessage <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> message<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Two arguments, the overload
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersPrintMessage <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> message, <span style="color: #6666cc; font-weight: bold;">int</span> count<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF; font-weight: bold;">Return</span> value with
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> TheCodersGetMessage <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Overrides
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">virtual</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersOverridableMethod <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Overrides
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersOverridableMethod <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Redefinition
<span style="color: #0600FF; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> TheCodersReDeclareMethod <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code103'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137103"><td class="code" id="p137code103"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> TheCodersDoSomething <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: #008080; font-style: italic;">'In argument</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> TheCodersPrintMessage <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> message <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
<span style="color: #008080; font-style: italic;">'Two Arguments, Overloading</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> TheCodersPrintMessage <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> message <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>, <span style="color: #FF8000;">ByVal</span> count <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'In Returns</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> TheCodersGetMessage <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Can override</span>
<span style="color: #FF8000;">Public</span> <span style="color: #FF8000;">Overridable</span> <span style="color: #0600FF;">Sub</span> TheCodersOverridableMethod <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: #008080; font-style: italic;">'Override</span>
<span style="color: #FF8000;">Public</span> <span style="color: #FF8000;">Overrides</span> <span style="color: #0600FF;">Sub</span> TheCodersOverridableMethod <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: #008080; font-style: italic;">'Redefining</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Shadows</span> <span style="color: #0600FF;">Sub</span> TheCodersReDeclareMethod <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h4>Properties</h4>
<p>Properties</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code104'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137104"><td class="code" id="p137code104"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> name<span style="color: #008000;">;</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Properties
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name <span style="color: #008000;">&#123;</span>
get <span style="color: #008000;">&#123;</span><span style="color: #0600FF; font-weight: bold;">return</span> name<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
set <span style="color: #008000;">&#123;</span>name <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Read<span style="color: #008000;">-</span>only property
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> TheCodersReadOnlyName <span style="color: #008000;">&#123;</span>
get <span style="color: #008000;">&#123;</span><span style="color: #0600FF; font-weight: bold;">return</span> name<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code105'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137105"><td class="code" id="p137code105"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Private</span> _name <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
<span style="color: #008080; font-style: italic;">'Properties</span>
<span style="color: #FF8000;">Public</span> <span style="color: #FF8000;">Property</span> Name <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
<span style="color: #FF8000;">Get</span>
<span style="color: #FF8000;">Return</span> _name
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">Get</span>
<span style="color: #FF8000;">Set</span> <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> value <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
_name <span style="color: #008000;">=</span> value
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">Set</span>
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">Property</span>
&nbsp;
<span style="color: #008080; font-style: italic;">'Read-only property</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">ReadOnly</span> <span style="color: #FF8000;">Property</span> TheCodersReadOnlyName <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
<span style="color: #FF8000;">Get</span>
<span style="color: #FF8000;">Return</span> _name
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">Get</span>
<span style="color: #0600FF;">End</span> <span style="color: #FF8000;">Property</span></pre></td></tr></table></div>

<h4>Generic</h4>
<p>Generic</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code106'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137106"><td class="code" id="p137code106"><pre class="csharp" style="font-family:monospace;">List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> strList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
strList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span> <span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Venu&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
strList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span> <span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Thomas&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #6666cc; font-weight: bold;">Class</span> definition
<span style="color: #6666cc; font-weight: bold;">class</span> GenericTheCoders <span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;</span>  <span style="color: #008000;">&#123;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> T heCodersGetValue <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code107'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137107"><td class="code" id="p137code107"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> strList <span style="color: #FF8000;">As</span> List <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> List <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span>
strList. <span style="color: #0000FF;">Add</span> <span style="color: #000000;">&#40;</span> <span style="color: #808080;">&quot;Venu&quot;</span><span style="color: #000000;">&#41;</span>
strList. <span style="color: #0000FF;">Add</span> <span style="color: #000000;">&#40;</span> <span style="color: #808080;">&quot;Thomas&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> <span style="color: #0600FF;">Class</span> definition <span style="color: #0600FF;">Class</span> GenericTheCoders <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> T<span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> heCodersGetValue <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> T
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

<h4>Nullable Types</h4>
<p>Nullable there.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code108'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137108"><td class="code" id="p137code108"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code109'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137109"><td class="code" id="p137code109"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> i <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span></pre></td></tr></table></div>

<h4>Type inference</h4>
<p>Type inference, it is. NET 3.5 (C # 3.0, VB9) function from</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code110'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137110"><td class="code" id="p137code110"><pre class="csharp" style="font-family:monospace;">var strVal <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Welcome&quot;</span><span style="color: #008000;">;</span>
var intVal <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code111'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137111"><td class="code" id="p137code111"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> strVal <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Welcome&quot;</span>
<span style="color: #0600FF;">Dim</span> intVal <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span></pre></td></tr></table></div>

<h4>Lambda expression</h4>
<p>Lambda expression</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code112'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137112"><td class="code" id="p137code112"><pre class="csharp" style="font-family:monospace;">Func <span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span>, <span style="color: #6666cc; font-weight: bold;">int</span>, <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span> func <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>a, b<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> a <span style="color: #008000;">*</span> b<span style="color: #008000;">;</span>
func <span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code113'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137113"><td class="code" id="p137code113"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> <span style="color: #FF8000;">func</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">Func</span> <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Of</span> <span style="color: #FF0000;">Integer</span>, <span style="color: #FF0000;">Integer</span>, <span style="color: #FF0000;">Integer</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">Function</span> <span style="color: #000000;">&#40;</span>a, b<span style="color: #000000;">&#41;</span> a <span style="color: #008000;">*</span> b
<span style="color: #FF8000;">func</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

<p>Also write this</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code114'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137114"><td class="code" id="p137code114"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> <span style="color: #FF8000;">func</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">Function</span> <span style="color: #000000;">&#40;</span>a <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span>, b <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span><span style="color: #000000;">&#41;</span> a <span style="color: #008000;">*</span> b</pre></td></tr></table></div>

<p>VB.NET smarter than the type inference</p>
<h4><strong>Directives preprocessor</strong></h4>
<p>VB I was able to</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code115'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137115"><td class="code" id="p137code115"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080;"># define TheCoders</span>
&nbsp;
<span style="color: #008080;"># if TheCoders</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> TheCoders
<span style="color: #008080;"># else</span>
<span style="color: #008000;">/</span> <span style="color: #008000;">/</span> Not TheCoders
<span style="color: #008080;"># endif</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code116'); return false;">View Code</a> VBNET</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p137116"><td class="code" id="p137code116"><pre class="vbnet" style="font-family:monospace;"># <span style="color: #0600FF;">Const</span> TheCoders <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
&nbsp;
# <span style="color: #0600FF;">If</span> TheCoders
<span style="color: #008080; font-style: italic;">'TheCoders</span>
# <span style="color: #FF8000;">Else</span>
<span style="color: #008080; font-style: italic;">'Not TheCoders</span>
# <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></pre></td></tr></table></div>

<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/03/c-from-vbnet/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/03/c-from-vbnet/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/03/c-from-vbnet/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

