<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Uadeeb's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 30 Aug 2008 04:20:03 GMT</pubDate>
    <description>DZone Snippets: Uadeeb's Code Snippets</description>
    <item>
      <title>ValidateForm()</title>
      <link>http://snippets.dzone.com/posts/show/4286</link>
      <description>// ValidateForm()&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    Private Function ValidateForm() As FormValidity&lt;br /&gt;&lt;br /&gt;        Dim MyReturn As New FormValidity&lt;br /&gt;        Dim ReturnString As New StringBuilder&lt;br /&gt;        Dim IsValidForm As Boolean = True&lt;br /&gt;&lt;br /&gt;        If (txtFirstName.Text = "") Then&lt;br /&gt;            ReturnString.Append("First Name")&lt;br /&gt;            txtFirstName.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            txtFirstName.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (txtLastName.Text = "") Then&lt;br /&gt;            ReturnString.Append(", Last Name")&lt;br /&gt;            txtLastName.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtLastName.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        Dim InputEmail As String = txtEmail.Text&lt;br /&gt;        Dim EmailExpression As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"&lt;br /&gt;        Dim Re As New Regex(EmailExpression)&lt;br /&gt;&lt;br /&gt;        If (Not Re.IsMatch(InputEmail)) Then&lt;br /&gt;            ReturnString.Append(", E-mail Address")&lt;br /&gt;            txtEmail.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtEmail.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (txtAdd1.Text = "") Then&lt;br /&gt;            ReturnString.Append(", Address 1")&lt;br /&gt;            txtAdd1.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtAdd1.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (txtCity.Text = "") Then&lt;br /&gt;            ReturnString.Append(", City")&lt;br /&gt;            txtCity.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtCity.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (ddlState.Text = "") Then&lt;br /&gt;            If (txtStateOther.Text = "") Then&lt;br /&gt;                ReturnString.Append(", State")&lt;br /&gt;                ddlState.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;                If (IsValidForm) Then ddlState.Focus()&lt;br /&gt;                IsValidForm = False&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (txtZip.Text = "") Then&lt;br /&gt;            ReturnString.Append(", Zip")&lt;br /&gt;            txtZip.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtZip.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (ddlCountry.Text = "") Then&lt;br /&gt;            ReturnString.Append(", Country")&lt;br /&gt;            ddlCountry.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then ddlCountry.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        If (txtPhone.Text = "") Then&lt;br /&gt;            ReturnString.Append(", Phone")&lt;br /&gt;            txtPhone.Attributes.Add("style", "background-color:#EBECED")&lt;br /&gt;            If (IsValidForm) Then txtPhone.Focus()&lt;br /&gt;            IsValidForm = False&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        MyReturn.IsValid = IsValidForm&lt;br /&gt;&lt;br /&gt;        If (ReturnString.ToString.StartsWith(",")) Then&lt;br /&gt;            MyReturn.FormFields = ReturnString.ToString.Substring(1)&lt;br /&gt;        Else&lt;br /&gt;            MyReturn.FormFields = ReturnString.ToString&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        Return MyReturn&lt;br /&gt;&lt;br /&gt;    End Function&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 11 Jul 2007 19:39:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4286</guid>
      <author>uadeeb (Umar)</author>
    </item>
    <item>
      <title>How to get all processes running on a machine</title>
      <link>http://snippets.dzone.com/posts/show/4272</link>
      <description>// Take a look at Process.GetProcesses(Environment.MachineName)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   Private Function KillAcrobat() As Boolean&lt;br /&gt;      Dim pAcrobat As Process&lt;br /&gt;      For Each pAcrobat In Process.GetProcesses(Environment.MachineName)&lt;br /&gt;         If pAcrobat.ProcessName = "Acrobat" Then pAcrobat.Kill()&lt;br /&gt;      Next&lt;br /&gt;   End Function&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 06 Jul 2007 15:18:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4272</guid>
      <author>uadeeb (Umar)</author>
    </item>
    <item>
      <title>Connection String entry in the web config file</title>
      <link>http://snippets.dzone.com/posts/show/4221</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;connectionStrings&gt;&lt;br /&gt; &lt;add name="SqlConnectionString"&lt;br /&gt;  connectionString="Data Source=localhost\BAND;Initial Catalog=Players;User ID=band;Password=letmein" /&gt;&lt;br /&gt;&lt;/connectionStrings&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 28 Jun 2007 20:44:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4221</guid>
      <author>uadeeb (Umar)</author>
    </item>
    <item>
      <title>Adding an entry at runtime in a DropDownList</title>
      <link>http://snippets.dzone.com/posts/show/4220</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DropDownList1.Items.Insert(0, new ListItem("-- All Manufacturers --", "0"));&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 28 Jun 2007 20:36:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4220</guid>
      <author>uadeeb (Umar)</author>
    </item>
    <item>
      <title>How to read stuff from file</title>
      <link>http://snippets.dzone.com/posts/show/4209</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public class Readtextfile&lt;br /&gt;{&lt;br /&gt; public static int Main(string[] args)&lt;br /&gt; {&lt;br /&gt;   StreamReader re = File.OpenText("Arungg.txt");&lt;br /&gt;   string input = null;&lt;br /&gt;   while ((input = re.ReadLine()) != null)&lt;br /&gt;   {&lt;br /&gt;     Console.WriteLine(input);&lt;br /&gt;   }&lt;br /&gt;   re.close;&lt;br /&gt;   return 0;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 25 Jun 2007 18:09:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4209</guid>
      <author>uadeeb (Umar)</author>
    </item>
    <item>
      <title>Walks all files and files in subfolders of the current folder recursively</title>
      <link>http://snippets.dzone.com/posts/show/4173</link>
      <description>// Walks all files and files in subfolders of the current folder&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   Private Sub WalkAllFiles(ByVal strPath As String, Optional ByVal IgnoreDupes As Boolean = False, Optional ByVal bOnlyPDFs As Boolean = True)&lt;br /&gt;        Dim arDirs() As DirectoryInfo&lt;br /&gt;        Dim oDir As New DirectoryInfo(strPath)&lt;br /&gt;        Dim arFiles(), oFile As FileInfo&lt;br /&gt;&lt;br /&gt;        'Get a list of files for the current directory'&lt;br /&gt;&lt;br /&gt;        Try&lt;br /&gt;            If bOnlyPDFs Then&lt;br /&gt;                arFiles = oDir.GetFiles("*.pdf")&lt;br /&gt;            Else&lt;br /&gt;                arFiles = oDir.GetFiles("*.*")&lt;br /&gt;            End If&lt;br /&gt;            For Each oFile In arFiles&lt;br /&gt;                sbpMain.Text = "Adding " + oFile.FullName&lt;br /&gt;                Try&lt;br /&gt;                    m_colWalkFiles.Add(oFile.FullName)&lt;br /&gt;                Catch ex As System.Exception&lt;br /&gt;                    If Not IgnoreDupes Then Throw New ArgumentException("Duplicate File.")&lt;br /&gt;                End Try&lt;br /&gt;            Next&lt;br /&gt;        Catch&lt;br /&gt;            //Discard the error&lt;br /&gt;        End Try&lt;br /&gt;        /*Process all files in subdirectories (recurse)*/&lt;br /&gt;        arDirs = oDir.GetDirectories()&lt;br /&gt;        For Each oDir In arDirs&lt;br /&gt;            WalkAllFiles(oDir.FullName, IgnoreDupes, bOnlyPDFs)&lt;br /&gt;        Next&lt;br /&gt;    End Sub&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 15:56:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4173</guid>
      <author>uadeeb (Umar)</author>
    </item>
  </channel>
</rss>
