<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>CodeKeep VB.NET Feed</title>
    <description>The latest and greatest VB.NET code snippets publicly available</description>
    <link>http://www.codekeep.net/feeds.aspx</link>
    <lastBuildDate>Tue, 08 May 2012 15:52:22 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>RSS.NET: http://www.rssdotnet.com/</generator>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CodeKeepVBNET" /><feedburner:info uri="codekeepvbnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Finding File Properties</title>
      <description>Description: Finding the last write time for a file along with pothers&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/5b5e8633-0ef8-4393-9436-a465ed078422.aspx'&gt;http://www.codekeep.net/snippets/5b5e8633-0ef8-4393-9436-a465ed078422.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Private Function ImportDate()
        Dim objFileInfo As New FileInfo(&amp;quot;C:\Documents and Settings\tbaggett\Desktop\XXDR606057_VP.xls&amp;quot;)

        Dim dtLastWriteTime As DateTime = objFileInfo.LastWriteTime

        Return dtLastWriteTime
    End Function&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/LMueEU08_uc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/LMueEU08_uc/5b5e8633-0ef8-4393-9436-a465ed078422.aspx</link>
      <pubDate>Tue, 08 May 2012 15:52:22 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/5b5e8633-0ef8-4393-9436-a465ed078422.aspx</feedburner:origLink></item>
    <item>
      <title>Creating a shortcut with hotkeys</title>
      <description>Description: Requires Imports IWshRuntimeLibrary and COM reference Windows Script Host Object&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/7c9a70ec-ccde-48ae-bc45-7e5cb878ff33.aspx'&gt;http://www.codekeep.net/snippets/7c9a70ec-ccde-48ae-bc45-7e5cb878ff33.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Public Sub CreateShortcut()
        Dim shell As WshShell = New WshShellClass 'Create new instance
        Dim shortcut As WshShortcut = shell.CreateShortcut(&amp;quot;C:\Documents and Settings\tbaggett\Desktop\RunDatasheet.lnk&amp;quot;) 'Path of the Shortcut - Where the Shortcut should be placed
        shortcut.TargetPath = &amp;quot;C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe&amp;quot; 'Exe of shortcut
        shortcut.IconLocation = &amp;quot;C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe,0&amp;quot; 'It's icon to use
        'shortcut.RelativePath = &amp;quot;C:\Program Files\Victory Packaging\Pipeline&amp;quot;
        shortcut.Hotkey = &amp;quot;Ctrl+Alt+S&amp;quot;
        shortcut.Description = &amp;quot;Launches RunDatasheet&amp;quot; 'It's description
        shortcut.Save() 'Save it.

    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/9W-8f90GqeQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/9W-8f90GqeQ/7c9a70ec-ccde-48ae-bc45-7e5cb878ff33.aspx</link>
      <pubDate>Tue, 24 Apr 2012 19:33:06 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/7c9a70ec-ccde-48ae-bc45-7e5cb878ff33.aspx</feedburner:origLink></item>
    <item>
      <title>Opening a ClickOnce from another ClickOnce</title>
      <description>Description: Also opening a word doc if the ClickOnce isn't installed&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/e1531c17-bda5-4ff9-9853-4f776afd5cb6.aspx'&gt;http://www.codekeep.net/snippets/e1531c17-bda5-4ff9-9853-4f776afd5cb6.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Private Sub cmdMarketByMiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMarketByMiles.Click

        Try
            System.Diagnostics.Process.Start(&amp;quot;C:\Documents and Settings\&amp;quot; &amp;amp; strUserName &amp;amp; &amp;quot;\Start Menu\Programs\Victory Packaging Golden State Container\CloseCall.appref-ms&amp;quot;)
        Catch ex As Exception
            MsgBox(&amp;quot;Please install CloseCall from the web site. You will be redirected there now.&amp;quot;)
            Dim doFirstTimeCloseCallInstructionsExist As Boolean
            doFirstTimeCloseCallInstructionsExist = DoesCloseCallInstructionsExist()

            Try
                Shell(&amp;quot;C:\Program Files\Microsoft Office\Office11\WINWORD.EXE &amp;quot;&amp;quot;C:\Documents and Settings\&amp;quot; &amp;amp; strUserName &amp;amp; &amp;quot;\Desktop\CLOSECALL FIRST TIME SETUP.docx&amp;quot;&amp;quot;&amp;quot;, AppWinStyle.NormalFocus)
            Catch exx As Exception
                Shell(&amp;quot;C:\Program Files\Microsoft Office\Office12\WINWORD.EXE &amp;quot;&amp;quot;C:\Documents and Settings\&amp;quot; &amp;amp; strUserName &amp;amp; &amp;quot;\Desktop\CLOSECALL FIRST TIME SETUP.docx&amp;quot;&amp;quot;&amp;quot;, AppWinStyle.NormalFocus)
            End Try

            System.Diagnostics.Process.Start(&amp;quot;http://www.victorypackagingsa.com/CloseCall&amp;quot;)

        End Try



    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/X2aDZrXPf7c" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/X2aDZrXPf7c/e1531c17-bda5-4ff9-9853-4f776afd5cb6.aspx</link>
      <pubDate>Tue, 24 Apr 2012 19:28:36 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/e1531c17-bda5-4ff9-9853-4f776afd5cb6.aspx</feedburner:origLink></item>
    <item>
      <title>Running a ClickOnce from another ClickOnce</title>
      <description>Description: This is how you can quit having to keep up with 2 programs with the exact code.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/fe60a58f-ead9-4176-90a3-78a2d689abe5.aspx'&gt;http://www.codekeep.net/snippets/fe60a58f-ead9-4176-90a3-78a2d689abe5.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Private Sub cmdMarketByMiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMarketByMiles.Click

        Try
            System.Diagnostics.Process.Start(&amp;quot;C:\Documents and Settings\&amp;quot; &amp;amp; strUserName &amp;amp; &amp;quot;\Start Menu\Programs\Victory Packaging Golden State Container\CloseCall.appref-ms&amp;quot;)
        Catch ex As Exception
            MsgBox(&amp;quot;Please install CloseCall from the web site.&amp;quot;)
            System.Diagnostics.Process.Start(&amp;quot;http://www.victorypackagingsa.com/CloseCall&amp;quot;)
        End Try
 End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/j7TxWWzwCAE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/j7TxWWzwCAE/fe60a58f-ead9-4176-90a3-78a2d689abe5.aspx</link>
      <pubDate>Mon, 23 Apr 2012 20:36:41 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/fe60a58f-ead9-4176-90a3-78a2d689abe5.aspx</feedburner:origLink></item>
    <item>
      <title>Opening a web page with a button</title>
      <description>Description: How to open a web page with just a button click&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/136813bf-4258-4961-b1b5-a0929abca148.aspx'&gt;http://www.codekeep.net/snippets/136813bf-4258-4961-b1b5-a0929abca148.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; 	Try
            System.Diagnostics.Process.Start(&amp;quot;http://www.victorypackagingsa.com/CloseCall&amp;quot;)
        Catch ex As Exception
            MsgBox(&amp;quot;There was an error: &amp;quot; &amp;amp; ex.Message &amp;amp; ex.StackTrace)
        End Try&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/dA6lRfvFNnU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/dA6lRfvFNnU/136813bf-4258-4961-b1b5-a0929abca148.aspx</link>
      <pubDate>Mon, 23 Apr 2012 18:43:01 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/136813bf-4258-4961-b1b5-a0929abca148.aspx</feedburner:origLink></item>
    <item>
      <title>Outlook Task Loading</title>
      <description>Description: Open a taks in Outlook from a MTGC combo box&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/0ca2794f-e842-45b1-ae8d-8da4720fbe28.aspx'&gt;http://www.codekeep.net/snippets/0ca2794f-e842-45b1-ae8d-8da4720fbe28.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Private Sub Mtgc_Tasks_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mtgc_Tasks.SelectionChangeCommitted
        Dim _contains As Int16 = 0
        Dim leng As Int16 = 0
        Dim objOutlook As Outlook.Application = New Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim NewContact As Outlook.ContactItem = objOutlook.CreateItem(Outlook.OlItemType.olContactItem)
        Dim cntr As Integer
        Dim isFound As Boolean

        newContact.FullName = txtContactName.Text
        NewContact.CompanyName = txtCompanyName.Text

        objOutlook = New Outlook.Application
        objNS = objOutlook.Session

        Dim objAddressList As Outlook.MAPIFolder

        objAddressList = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

        Dim objItems As Outlook.Items = objAddressList.Items
        Dim objContact As Outlook.ContactItem
        Dim companyName As String = newContact.CompanyName

        For j As Int16 = 1 To objItems.Count
            Try
                objContact = objItems(j)
                If objContact.FullName = newContact.FullName.Trim And objContact.CompanyName.Trim = newContact.CompanyName.Trim Then
                    isFound = True
                    Dim ns As Outlook.NameSpace
                    Dim tasks As Outlook.Items
                    ns = objOutlook.GetNamespace(&amp;quot;MAPI&amp;quot;)
                    tasks = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items
                    Dim task As Object
                    If tasks.Count &amp;gt; 0 Then
                        taskArr = New List(Of TaskInfo)
                        For Each task In tasks
                            If task.subject = Mtgc_Tasks.SelectedItem.col2 Then
                                'Dim oTsk As Outlook.TaskItem = DirectCast(objOutlook.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem)

                                'oTsk.Status = Outlook.OlTaskStatus.olTaskInProgress
                                'oTsk.Subject = task.subject
                                'oTsk.PercentComplete = task.percentComplete
                                'oTsk.StartDate = task.startDate
                                'oTsk.DueDate = task.duedate
                                'oTsk.Importance = task.importance

                                'oTsk.Importance = Outlook.OlImportance.olImportanceHigh

                                task.Display()
                                objOutlook = Nothing
                                task = Nothing
                                Exit For

                            End If
                        Next
                    End If

                    Marshal.ReleaseComObject(objContact)
                    Exit For
                End If
                Marshal.ReleaseComObject(objContact)
                objContact = Nothing
            Catch ex As Exception
                MsgBox(&amp;quot;There was an error: &amp;quot; &amp;amp; ex.Message &amp;amp; ex.StackTrace)
            End Try

        Next
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/b2WkOGhOplg" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/b2WkOGhOplg/0ca2794f-e842-45b1-ae8d-8da4720fbe28.aspx</link>
      <pubDate>Mon, 26 Mar 2012 19:36:29 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/0ca2794f-e842-45b1-ae8d-8da4720fbe28.aspx</feedburner:origLink></item>
    <item>
      <title>DatagridView CellDoubleClick</title>
      <description>Description: Double clicking on a dgv&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/99e5c1bf-ffe2-41a3-bd62-455b94a6ae34.aspx'&gt;http://www.codekeep.net/snippets/99e5c1bf-ffe2-41a3-bd62-455b94a6ae34.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Private Sub dgv_Contacts_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_Contacts.CellDoubleClick

        rowSelected = e.RowIndex

        If rowSelected &amp;lt; 0 Then Exit Sub
        Dim sic As String = dgv_Contacts(&amp;quot;primarySic&amp;quot;, rowSelected).Value.ToString()
        Dim custNum As String = dgv_Contacts(&amp;quot;customerNum&amp;quot;, rowSelected).Value.ToString()

    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/ioCEg1Qz1S8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/ioCEg1Qz1S8/99e5c1bf-ffe2-41a3-bd62-455b94a6ae34.aspx</link>
      <pubDate>Thu, 15 Mar 2012 17:35:12 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/99e5c1bf-ffe2-41a3-bd62-455b94a6ae34.aspx</feedburner:origLink></item>
    <item>
      <title>Cabecera de XML y Agregado.</title>
      <description>Description: Caecera y ejemplo para agergar y crear un documento XML.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/60f081c0-200f-4e0f-b55c-071f899485ef.aspx'&gt;http://www.codekeep.net/snippets/60f081c0-200f-4e0f-b55c-071f899485ef.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;   'Crea el nuevo documento.
  Dim oDocXML As New XDocument 'nuevo XML doc.

  'Declaraci&amp;#243;n de tipo.
  oDocXML.Declaration = New XDeclaration(&amp;quot;1.0&amp;quot;, &amp;quot;utf-8&amp;quot;, &amp;quot;no&amp;quot;)

  'Crea el elemento Main.
  Dim oMainContratos As New XElement(&amp;quot;Contratos&amp;quot;)

  'Crea el elemento sub con sus atributos.
  Dim oSubContrato As New XElement(&amp;quot;Contrato&amp;quot;, New XAttribute() {New XAttribute(&amp;quot;Numero&amp;quot;, cboContrato.Text), New XAttribute(&amp;quot;Cuenta1&amp;quot;, cboCuenta.Text), New XAttribute(&amp;quot;Cuenta2&amp;quot;, &amp;quot;N/A&amp;quot;),
                                                         New XAttribute(&amp;quot;Nombre&amp;quot;, txtNombre.Text), New XAttribute(&amp;quot;Domicilio&amp;quot;, txtDomicilio.Text),
                                                         New XAttribute(&amp;quot;ALadoDe&amp;quot;, txtALadoDe.Text), New XAttribute(&amp;quot;FrenteA&amp;quot;, txtFrenteA.Text), New XAttribute(&amp;quot;EntreCalles&amp;quot;, txtEntreCalles.Text),
                                                         New XAttribute(&amp;quot;Colonia&amp;quot;, cboColonia.Text), New XAttribute(&amp;quot;CP&amp;quot;, txtCP.Text), New XAttribute(&amp;quot;Telefono&amp;quot;, txtTelefono.Text),
                                                         New XAttribute(&amp;quot;Celular&amp;quot;, txtCelular.Text), New XAttribute(&amp;quot;EMail&amp;quot;, txtEmail.Text), New XAttribute(&amp;quot;FachadaDomi&amp;quot;, txtFachadaDomi.Text),
                                                         New XAttribute(&amp;quot;Planta&amp;quot;, sPlanta), New XAttribute(&amp;quot;Zona&amp;quot;, cboZona.Text)})

 'Agrega al sub al main.
  oMainContratos.Add(oSubContrato)

  'Agrega el main al doc.
  oDocXML.Add(oMainContratos)

  'Salva el archivo.
  oDocXML.Save(Application.StartupPath &amp;amp; &amp;quot;\cts\Contrs.bin&amp;quot;)&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/ZQxqdFpKPmM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/ZQxqdFpKPmM/60f081c0-200f-4e0f-b55c-071f899485ef.aspx</link>
      <pubDate>Sun, 19 Feb 2012 03:12:18 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/60f081c0-200f-4e0f-b55c-071f899485ef.aspx</feedburner:origLink></item>
    <item>
      <title>Descargar el Código HTML de una pagina web</title>
      <description>Description: Descargar el Código HTML de una pagina web&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/6b6b453f-af80-4797-874e-1fe14f678941.aspx'&gt;http://www.codekeep.net/snippets/6b6b453f-af80-4797-874e-1fe14f678941.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(&amp;quot;http://www.whatismyip.com/&amp;quot;)
  Dim response As System.Net.HttpWebResponse = request.GetResponse()

  Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

  Dim sourcecode As String = sr.ReadToEnd()
  TextBox1.Text = sourcecode
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/c2drGK-HSm0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/c2drGK-HSm0/6b6b453f-af80-4797-874e-1fe14f678941.aspx</link>
      <pubDate>Sat, 18 Feb 2012 16:45:32 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/6b6b453f-af80-4797-874e-1fe14f678941.aspx</feedburner:origLink></item>
    <item>
      <title>Outlook Tasks</title>
      <description>Description: Adding tasks to outlook&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/9e080004-e1b9-4f36-a21c-0e511cad442f.aspx'&gt;http://www.codekeep.net/snippets/9e080004-e1b9-4f36-a21c-0e511cad442f.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Private Sub cmdAddTask_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddTask.Click
        Dim oApp As Outlook.Application = New Outlook.Application
        Dim cntr As Integer = 0

        If Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;lt; 1 Then
            'restarts the Process 
            Process.Start(&amp;quot;OutLook.exe&amp;quot;)
            Do Until Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;gt;= 1
                cntr += 1
            Loop
        End If

        Dim oTsk As Outlook.TaskItem = DirectCast(oApp.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem)

        oTsk.Status = Outlook.OlTaskStatus.olTaskInProgress

        'oTsk.PercentComplete = 0

        'oTsk.Importance = Outlook.OlImportance.olImportanceHigh

        oTsk.Subject = &amp;quot;New task for &amp;quot; &amp;amp; txtCompanyName.Text
        oTsk.Display()
        'oTsk.Save()

        ' Clean up.

        oApp = Nothing

        oTsk = Nothing

    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/8V-bC3xsnNs" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/8V-bC3xsnNs/9e080004-e1b9-4f36-a21c-0e511cad442f.aspx</link>
      <pubDate>Tue, 14 Feb 2012 22:10:21 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/9e080004-e1b9-4f36-a21c-0e511cad442f.aspx</feedburner:origLink></item>
    <item>
      <title>Outlook Contact Search</title>
      <description>Description: Looping through contacts&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/5174618c-62c3-4630-a39b-a9b10b60cec8.aspx'&gt;http://www.codekeep.net/snippets/5174618c-62c3-4630-a39b-a9b10b60cec8.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Private Sub GetContact(ByVal _name As String)
        Dim first As String = &amp;quot;&amp;quot;
        Dim _contains As Int16 = 0
        Dim last As String = &amp;quot;&amp;quot;
        Dim isFound As Boolean
        Dim leng As Int16 = 0
        Dim objOutlook As Outlook.Application = New Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim NewContact As Outlook.ContactItem = objOutlook.CreateItem(Outlook.OlItemType.olContactItem)
        NewContact.FullName = txtContactName.Text
        Dim name As String = NewContact.FullName
        If name Is Nothing Then Exit Sub
        _contains = InStr(name, &amp;quot; &amp;quot;)
        leng = name.Length
        If _contains &amp;gt; 0 Then
            name = name.Substring(0, _contains - 1)
            first = name
            last = NewContact.FullName.Substring(_contains, leng - _contains)
            NewContact.FirstName = first
            NewContact.LastName = last
        End If

        NewContact.CompanyName = txtCompanyName.Text

        objOutlook = New Outlook.Application()
        objNS = objOutlook.Session

        Dim objAddressList As Outlook.MAPIFolder
        objAddressList = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

        Dim objItems As Outlook.Items = objAddressList.Items
        Dim objContact As Outlook.ContactItem

        For j As Int16 = 1 To objItems.Count
            Try
                objContact = objItems(j)
                If objContact.FullName = NewContact.FullName And objContact.CompanyName = NewContact.CompanyName Then
                    isFound = True
                    Marshal.ReleaseComObject(objContact)
                    Exit For
                End If
                Marshal.ReleaseComObject(objContact)
                objContact = Nothing
            Catch ex As Exception

            End Try

        Next

        If isFound = True Then
            cmdCreateContact.Image = Image.FromFile(&amp;quot;C:\AAAVictoryProgramming\PipelineProject\contact.bmp&amp;quot;)
            cmdCreateContact.Text = &amp;quot;Contact&amp;quot;
        Else
            cmdCreateContact.Image = Nothing
            cmdCreateContact.Text = &amp;quot;Create Contact&amp;quot;
        End If

        objContact = Nothing
        objItems = Nothing
        objAddressList = Nothing

    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/chLn0Yif154" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/chLn0Yif154/5174618c-62c3-4630-a39b-a9b10b60cec8.aspx</link>
      <pubDate>Tue, 14 Feb 2012 17:08:22 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/5174618c-62c3-4630-a39b-a9b10b60cec8.aspx</feedburner:origLink></item>
    <item>
      <title>Outlook - Add Contact</title>
      <description>Description: Adding a contact to Outlook from a form&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/ac847f43-ab8f-4068-89f1-18d3093f50d9.aspx'&gt;http://www.codekeep.net/snippets/ac847f43-ab8f-4068-89f1-18d3093f50d9.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Imports Microsoft.Office.Interop


If Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;lt; 1 Then
            'restarts the Process 
            Process.Start(&amp;quot;OutLook.exe&amp;quot;)
            Do Until Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;gt;= 1
                cntr += 1
            Loop
        End If
        Dim outApplication As Outlook.Application = New Outlook.Application()
        Dim xNS As Outlook.NameSpace = outApplication.GetNamespace(&amp;quot;mapi&amp;quot;)
        xNS.Logon(&amp;quot;YourValidProfile&amp;quot;, Missing.Value, False, True)
        ' Create an Outlook application.


        ' Get the namespace and the logon.
        Dim outNamSpace As Outlook.NameSpace = outApplication.GetNamespace(&amp;quot;MAPI&amp;quot;)

        ' Create a new contact item.
        Dim NewContact As Outlook.ContactItem = outApplication.CreateItem(Outlook.OlItemType.olContactItem)

        ' Set some common properties.

        NewContact.FullName = txtContactName.Text

        Dim first As String = &amp;quot;&amp;quot;
        Dim _contains As Int16 = 0
        Dim last As String = &amp;quot;&amp;quot;
        Dim name As String = NewContact.FullName
        Dim leng As Int16 = 0

        _contains = InStr(name, &amp;quot; &amp;quot;)
        leng = name.Length

        If _contains &amp;gt; 0 Then
            name = name.Substring(0, _contains - 1)
            first = name
            last = NewContact.FullName.Substring(_contains, leng - _contains)

            _yes = MsgBox(&amp;quot;Is the first name &amp;quot; &amp;amp; first &amp;amp; &amp;quot;, y or n?&amp;quot;, MsgBoxStyle.YesNo)
            If _yes = MsgBoxResult.Yes Then
                NewContact.FirstName = first
            End If

            _yes = MsgBox(&amp;quot;Is the last name &amp;quot; &amp;amp; last &amp;amp; &amp;quot;, y or n?&amp;quot;, MsgBoxStyle.YesNo)
            If _yes = MsgBoxResult.Yes Then
                NewContact.LastName = last
            End If
        End If

        NewContact.CompanyName = txtCompanyName.Text
        Select Case cboStage.Text
            Case &amp;quot;1-Customer/Closed/In Transition&amp;quot;
                'NewContact.Title = &amp;quot;Client&amp;quot;
                NewContact.Categories = &amp;quot;Blue Category&amp;quot;
            Case &amp;quot;2-Proposal Submitted/Waiting Decision&amp;quot;
                NewContact.Categories = &amp;quot;Green Category&amp;quot;
            Case &amp;quot;3-Prospect/Finalizing Proposal&amp;quot;
                NewContact.Categories = &amp;quot;Green Category&amp;quot;
            Case &amp;quot;4-Prospect/Assessing/Developing Deal&amp;quot;
                NewContact.Categories = &amp;quot;Green Category&amp;quot;
            Case &amp;quot;5-Suspect/Potential Prospect&amp;quot;
                NewContact.Categories = &amp;quot;Green Category&amp;quot;
            Case &amp;quot;6-Submitted Proposal/Lost&amp;quot;
                NewContact.Categories = &amp;quot;Red Category&amp;quot;
            Case &amp;quot;7-Pass on Deal / Not a Fit&amp;quot;
                NewContact.Categories = &amp;quot;Red Category&amp;quot;
        End Select

        If txtComments.Text &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then NewContact.Body = txtComments.Text
        'NewContact.Birthday = Convert.ToDateTime(&amp;quot;5/4/1969&amp;quot;)
        'NewContact.Department = &amp;quot;Development&amp;quot;
        'NewContact.FileAs = &amp;quot;Authorcode&amp;quot;
        'NewContact.Email1Address = &amp;quot;abc@hotmail.com&amp;quot;
        'NewContact.Email2Address = &amp;quot;abc@live.com&amp;quot;
        'NewContact.MailingAddress = &amp;quot;NewDelhi India&amp;quot;
        'NewContact.Subject = &amp;quot;Contact crated from vb.net&amp;quot;
        'NewContact.JobTitle = &amp;quot;Engineer&amp;quot;

        Dim oContacts As Outlook.MAPIFolder = xNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
        Dim oItems As Outlook.Items = oContacts.Items


        ' Get the first contacts
    
    Outlook automatically looks for duplicate and asks
        'For i As Integer = 1 To oItems.Count
        '    Dim xCont As Outlook.ContactItem
        '    xCont = oItems(i)
        '    If xCont.FullName = NewContact.FullName And xCont.CompanyName = NewContact.CompanyName Then
        '        MsgBox(&amp;quot;That contact has already been created.&amp;quot;)
        '        xCont.Display()
        '        Exit Sub
        '    End If
        'Next

        NewContact.Display()
        'NewContact.Save()

        outApplication = Nothing
        outNamSpace = Nothing
        NewContact = Nothing&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/TBu3Z6AfDnw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/TBu3Z6AfDnw/ac847f43-ab8f-4068-89f1-18d3093f50d9.aspx</link>
      <pubDate>Thu, 09 Feb 2012 15:59:17 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/ac847f43-ab8f-4068-89f1-18d3093f50d9.aspx</feedburner:origLink></item>
    <item>
      <title>Threading a Sql update</title>
      <description>Description: This one is simpler than most&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/63211be1-6ed8-49b1-b725-c56eeb72a764.aspx'&gt;http://www.codekeep.net/snippets/63211be1-6ed8-49b1-b725-c56eeb72a764.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Imports System.Threading
'threadSub
Dim op As New ParameterizedThreadStart(AddressOf CreateSQLCompany)
            Dim newThread As New Thread(op)
            newThread.Start(sqlCompany)
'end thread sub

Private Sub CreateSQLCompany(ByVal comp As Object)
        Try
            CompanyInfoData.Instance.CreateSql(comp)
        Catch ex As Exception
            MsgBox(&amp;quot;There was an error: &amp;quot; &amp;amp; ex.Message &amp;amp; ex.StackTrace)
        End Try
End Sub
 
Private Delegate Sub UIdelegate()&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/mAW41STLYTY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/mAW41STLYTY/63211be1-6ed8-49b1-b725-c56eeb72a764.aspx</link>
      <pubDate>Mon, 30 Jan 2012 19:13:18 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/63211be1-6ed8-49b1-b725-c56eeb72a764.aspx</feedburner:origLink></item>
    <item>
      <title>File creation and deletion</title>
      <description>Description: Finding a file deleting and re-adding it&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/8c162f0a-80e4-482d-92ba-11a5aab34bf8.aspx'&gt;http://www.codekeep.net/snippets/8c162f0a-80e4-482d-92ba-11a5aab34bf8.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Public Sub CreateRunDatasheet()
        Dim fileSource As String = &amp;quot;\\srvfile1\PipelineUsers\Databases\Pipeline\&amp;quot;
        Dim fileDestination As String = &amp;quot;C:\Program Files\Victory Packaging\Pipeline&amp;quot;
        Dim fileName As String = &amp;quot;RunDatasheet.exe&amp;quot;
        Dim fMsg As New WaitingForm
        Dim deleteFile As String = &amp;quot;C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe&amp;quot;
        'create a new object for the message form
        fMsg.TopMost = True                'this is to make sure that the message form is displayed at the top of your windows and the users cannot do anything to it except waiting
        fMsg.Show()

        If File.Exists(deleteFile) Then
            File.Delete(deleteFile)
        End If

        My.Computer.FileSystem.CopyFile(fileSource &amp;amp; &amp;quot;\&amp;quot; &amp;amp; fileName, fileDestination &amp;amp; &amp;quot;\&amp;quot; &amp;amp; fileName)

        fMsg.Close()
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/BuIfUC1BF-o" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/BuIfUC1BF-o/8c162f0a-80e4-482d-92ba-11a5aab34bf8.aspx</link>
      <pubDate>Thu, 26 Jan 2012 21:32:31 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/8c162f0a-80e4-482d-92ba-11a5aab34bf8.aspx</feedburner:origLink></item>
    <item>
      <title>Desktop shortcut and hotkeys</title>
      <description>Description: Creating a shortcut programatically&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/5c91bd84-a5a9-4bf5-8bc7-b1e6a7d5a366.aspx'&gt;http://www.codekeep.net/snippets/5c91bd84-a5a9-4bf5-8bc7-b1e6a7d5a366.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;'you must add the reference Com Windows Script Host Object Model
Imports IWshRuntimeLibrary

Private Sub CreateShortcut()
        Dim shell As WshShell = New WshShellClass 'Create new instance
        Dim shortcut As WshShortcut = shell.CreateShortcut(&amp;quot;C:\Documents and Settings\tbaggett\Desktop\RunDatasheet.lnk&amp;quot;) 'Path of the Shortcut - Where the Shortcut should be placed
        shortcut.TargetPath = &amp;quot;C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe&amp;quot; 'Exe of shortcut
        shortcut.IconLocation = &amp;quot;C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe,0&amp;quot; 'It's icon to use
        shortcut.Hotkey = &amp;quot;Ctrl+Alt+S&amp;quot;
        shortcut.Description = &amp;quot;Launches RunDatasheet&amp;quot; 'It's description
        shortcut.Save() 'Save it.
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/iejdGjJyNPE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/iejdGjJyNPE/5c91bd84-a5a9-4bf5-8bc7-b1e6a7d5a366.aspx</link>
      <pubDate>Thu, 26 Jan 2012 21:25:30 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/5c91bd84-a5a9-4bf5-8bc7-b1e6a7d5a366.aspx</feedburner:origLink></item>
    <item>
      <title>GetGroupsCounts</title>
      <description>Description: Get a list of occurrence counts of all items in a List.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/d409e77a-a864-4b28-ad06-a5f8290bfcf6.aspx'&gt;http://www.codekeep.net/snippets/d409e77a-a864-4b28-ad06-a5f8290bfcf6.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;    Private Function GetGroups(fullList As List(Of String)) As List(Of Tuple(Of String, Integer))
        Dim groups As New List(Of Tuple(Of String, Integer))

        Dim result = From i In fullList
                     Group i By i Into Group
                     Order By Group.Count() Descending
                     Select i, Count = Group.Count()

        For Each item In result
            Dim group As New Tuple(Of String, Integer)(item.i, item.Count)
            groups.Add(group)
        Next

        Return groups
    End Function&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/fRpDvjhuvOA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/fRpDvjhuvOA/d409e77a-a864-4b28-ad06-a5f8290bfcf6.aspx</link>
      <pubDate>Tue, 24 Jan 2012 07:49:10 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/d409e77a-a864-4b28-ad06-a5f8290bfcf6.aspx</feedburner:origLink></item>
    <item>
      <title>Get Count of Item Occurrences in a List of String</title>
      <description>Description: Two ways to the the count of a specified string in a list of strings.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/b0fd0c18-68ce-43a9-a95f-2bd690e92a47.aspx'&gt;http://www.codekeep.net/snippets/b0fd0c18-68ce-43a9-a95f-2bd690e92a47.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;    Private Function GetOccurrencesCount(valueToFind As String, fullList As List(Of String)) As Integer
        Dim count As Integer = (From temp In fullList
                                Where temp.Equals(valueToFind)
                                Select temp).Count

        Return count
    End Function

    Private Function GetOccurrencesCount2(valueToFind As String, fullList As List(Of String)) As Integer
        Dim count As Integer = fullList.Where(Function(temp) temp.Equals(valueToFind)).Select(Function(temp) temp).Count

        Return count
    End Function&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/l4U9_AinTCE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/l4U9_AinTCE/b0fd0c18-68ce-43a9-a95f-2bd690e92a47.aspx</link>
      <pubDate>Tue, 24 Jan 2012 07:46:42 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/b0fd0c18-68ce-43a9-a95f-2bd690e92a47.aspx</feedburner:origLink></item>
    <item>
      <title>Update a progress bar in a loop in WPF</title>
      <description>Description: Progress bars don't update in WPF when they're incremented from within a loop and there's no DoEvents to use.  This will sort it out.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/9df57f1f-be01-446b-88cf-927874369ed0.aspx'&gt;http://www.codekeep.net/snippets/9df57f1f-be01-446b-88cf-927874369ed0.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;    Private Sub IncremenetProgressBarDelegate()
        ProgressBar1.Value += 1
    End Sub

    Private Sub IncrementProgressBar()
        Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, New Action(AddressOf IncremenetProgressBarDelegate))
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/XLtIRnKEPrw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/XLtIRnKEPrw/9df57f1f-be01-446b-88cf-927874369ed0.aspx</link>
      <pubDate>Fri, 13 Jan 2012 10:01:34 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/9df57f1f-be01-446b-88cf-927874369ed0.aspx</feedburner:origLink></item>
    <item>
      <title>Checking to see if a program is running</title>
      <description>Description: If the program isn't running then it will open.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/bb6915e7-a8e3-4a90-9699-e40f406acec7.aspx'&gt;http://www.codekeep.net/snippets/bb6915e7-a8e3-4a90-9699-e40f406acec7.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; If Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;lt; 1 Then
            'restarts the Process 
            Process.Start(&amp;quot;OutLook.exe&amp;quot;)
            Do Until Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;gt;= 1
                cntr += 1
            Loop
        End If&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/U3zHy3vmgcM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/U3zHy3vmgcM/bb6915e7-a8e3-4a90-9699-e40f406acec7.aspx</link>
      <pubDate>Wed, 11 Jan 2012 20:21:55 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/bb6915e7-a8e3-4a90-9699-e40f406acec7.aspx</feedburner:origLink></item>
    <item>
      <title>Outlook Appointment Automation</title>
      <description>Description: Add an appointment to Outlook.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/713cf921-6647-4890-9c63-b4486317a03e.aspx'&gt;http://www.codekeep.net/snippets/713cf921-6647-4890-9c63-b4486317a03e.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;    Private Sub cmdCreateAppt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreateAppt.Click
        If Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;lt; 1 Then
            'restarts the Process 
            Process.Start(&amp;quot;OutLook.exe&amp;quot;)
            Do Until Process.GetProcessesByName(&amp;quot;OutLook&amp;quot;).Length &amp;gt;= 1
                cntr += 1
            Loop
        End If

        Dim oApp As Outlook.Application = New Outlook.Application()

        ' Get NameSpace and Logon.
        Dim oNS As Outlook.NameSpace = oApp.GetNamespace(&amp;quot;mapi&amp;quot;)
        oNS.Logon(r.UserName, Missing.Value, False, True)

        ' Create a new AppointmentItem.
        Dim oAppt As Outlook.AppointmentItem = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
        'oAppt.Display(true)  'Modal    

        ' Set some common properties.
        If txtCompanyName.Text = &amp;quot;&amp;quot; Then
            oAppt.Location = InputBox(&amp;quot;Enter in the company name or appointment place.&amp;quot;)
        Else
            oAppt.Location = txtCompanyName.Text
        End If

        oAppt.Subject = InputBox(&amp;quot;Enter in the subject of the appt.&amp;quot;)
        oAppt.Body = InputBox(&amp;quot;Enter in the body message.&amp;quot;)

        Dim _date As Date = OutlookDatePicker.Text

        Dim _time As Date = OutlookTimePicker.Text

        oAppt.Start = Convert.ToDateTime(_date &amp;amp; &amp;quot; &amp;quot; &amp;amp; _time)

        oAppt.Duration = InputBox(&amp;quot;Enter in the appt. duration you expect.&amp;quot;)
        oAppt.End = oAppt.Start.AddMinutes(oAppt.Duration)
        oAppt.ReminderSet = True
        oAppt.ReminderMinutesBeforeStart = 15
        oAppt.BusyStatus = Outlook.OlBusyStatus.olBusy
        oAppt.IsOnlineMeeting = False

        ' Save to Calendar.
        oAppt.Save()

        ' Display.
        oAppt.Display(True)

        ' Logoff.
        oNS.Logoff()

        ' Clean up.
        oApp = Nothing
        oNS = Nothing
        oAppt = Nothing
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/OccpXEQ6UWQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/OccpXEQ6UWQ/713cf921-6647-4890-9c63-b4486317a03e.aspx</link>
      <pubDate>Wed, 11 Jan 2012 19:02:07 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/713cf921-6647-4890-9c63-b4486317a03e.aspx</feedburner:origLink></item>
    <item>
      <title>ComboBox validation</title>
      <description>Description: Making sure the text entered in a combo box is one of the selections&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/ab9d9502-2025-4e32-abfb-3d4dba633532.aspx'&gt;http://www.codekeep.net/snippets/ab9d9502-2025-4e32-abfb-3d4dba633532.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Private Sub cboStage_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboStage.Leave
        Dim dRow As DataRow
        Dim dCol As DataColumn
        Dim dt As New DataTable
        Dim isFound As Boolean
        Dim str As String = &amp;quot;&amp;quot;

        If cboStage.Text &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then
            dt = stages.BuildStages
            For i As Int16 = 0 To dt.Rows.Count - 1
                dRow = dt.Rows(i)
                If dRow(&amp;quot;stage&amp;quot;) = cboStage.Text Then
                    isFound = True
                    Exit For
                End If
            Next
            If isFound = False Then
                MsgBox(&amp;quot;You must make a selection from the list.&amp;quot;)
                cboStage.Text = &amp;quot;&amp;quot;
                Exit Sub
            End If
        End If
    End Sub&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/aUCd1WkYC5s" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/aUCd1WkYC5s/ab9d9502-2025-4e32-abfb-3d4dba633532.aspx</link>
      <pubDate>Tue, 10 Jan 2012 14:45:59 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/ab9d9502-2025-4e32-abfb-3d4dba633532.aspx</feedburner:origLink></item>
    <item>
      <title>NumberToWords</title>
      <description>Description: NumberToWords&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/f6ec6753-8ba3-41a3-b113-ee8f5cc97553.aspx'&gt;http://www.codekeep.net/snippets/f6ec6753-8ba3-41a3-b113-ee8f5cc97553.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Public Class NumberToWords
    'Public Class clsConversion

    Dim mOnesArray(8) As String
    Dim mOneTensArray(9) As String
    Dim mTensArray(7) As String
    Dim mPlaceValues(4) As String


    Public Sub New()

        mOnesArray(0) = &amp;quot;One&amp;quot;
        mOnesArray(1) = &amp;quot;Two&amp;quot;
        mOnesArray(2) = &amp;quot;Three&amp;quot;
        mOnesArray(3) = &amp;quot;Four&amp;quot;
        mOnesArray(4) = &amp;quot;Five&amp;quot;
        mOnesArray(5) = &amp;quot;Six&amp;quot;
        mOnesArray(6) = &amp;quot;Seven&amp;quot;
        mOnesArray(7) = &amp;quot;Eight&amp;quot;
        mOnesArray(8) = &amp;quot;Nine&amp;quot;

        mOneTensArray(0) = &amp;quot;Ten&amp;quot;
        mOneTensArray(1) = &amp;quot;Eleven&amp;quot;
        mOneTensArray(2) = &amp;quot;Twelve&amp;quot;
        mOneTensArray(3) = &amp;quot;Thirteen&amp;quot;
        mOneTensArray(4) = &amp;quot;Fourteen&amp;quot;
        mOneTensArray(5) = &amp;quot;Fifteen&amp;quot;
        mOneTensArray(6) = &amp;quot;Sixteen&amp;quot;
        mOneTensArray(7) = &amp;quot;Seventeen&amp;quot;
        mOneTensArray(8) = &amp;quot;Eighteen&amp;quot;
        mOneTensArray(9) = &amp;quot;Nineteen&amp;quot;

        mTensArray(0) = &amp;quot;Twenty&amp;quot;
        mTensArray(1) = &amp;quot;Thirty&amp;quot;
        mTensArray(2) = &amp;quot;Forty&amp;quot;
        mTensArray(3) = &amp;quot;Fifty&amp;quot;
        mTensArray(4) = &amp;quot;Sixty&amp;quot;
        mTensArray(5) = &amp;quot;Seventy&amp;quot;
        mTensArray(6) = &amp;quot;Eighty&amp;quot;
        mTensArray(7) = &amp;quot;Ninety&amp;quot;

        mPlaceValues(0) = &amp;quot;Hundred&amp;quot;
        mPlaceValues(1) = &amp;quot;Thousand&amp;quot;
        mPlaceValues(2) = &amp;quot;Million&amp;quot;
        mPlaceValues(3) = &amp;quot;Billion&amp;quot;
        mPlaceValues(4) = &amp;quot;Trillion&amp;quot;

    End Sub


    Protected Function GetOnes(ByVal OneDigit As Integer) As String

        GetOnes = &amp;quot;&amp;quot;

        If OneDigit = 0 Then
            Exit Function
        End If

        GetOnes = mOnesArray(OneDigit - 1)

    End Function


    Protected Function GetTens(ByVal TensDigit As Integer) As String

        GetTens = &amp;quot;&amp;quot;

        If TensDigit = 0 Or TensDigit = 1 Then
            Exit Function
        End If

        GetTens = mTensArray(TensDigit - 2)

    End Function


    Public Function ConvertNumberToWords(ByVal NumberValue As String) As String

        Dim Delimiter As String = &amp;quot; &amp;quot;
        Dim TensDelimiter As String = &amp;quot;-&amp;quot;
        Dim mNumberValue As String = &amp;quot;&amp;quot;
        Dim mNumbers As String = &amp;quot;&amp;quot;
        Dim mNumWord As String = &amp;quot;&amp;quot;
        Dim mFraction As String = &amp;quot;&amp;quot;
        Dim mNumberStack() As String
        Dim j As Integer = 0
        Dim i As Integer = 0
        Dim mOneTens As Boolean = False

        ConvertNumberToWords = &amp;quot;&amp;quot;

        ' validate input
        Try
            j = CDbl(NumberValue)
        Catch ex As Exception
            ConvertNumberToWords = &amp;quot;Invalid input.&amp;quot;
            Exit Function
        End Try

        ' get fractional part {if any}
        If InStr(NumberValue, &amp;quot;.&amp;quot;) = 0 Then
            ' no fraction
            mNumberValue = NumberValue
        Else
            mNumberValue = Microsoft.VisualBasic.Left(NumberValue, InStr(NumberValue, &amp;quot;.&amp;quot;) - 1)
            mFraction = Mid(NumberValue, InStr(NumberValue, &amp;quot;.&amp;quot;)) ' + 1)
            mFraction = Math.Round(CSng(mFraction), 2) * 100

            If CInt(mFraction) = 0 Then
                mFraction = &amp;quot;&amp;quot;
            Else
                mFraction = &amp;quot;&amp;amp;&amp;amp; &amp;quot; &amp;amp; mFraction &amp;amp; &amp;quot;/100&amp;quot;
            End If
        End If
        mNumbers = mNumberValue.ToCharArray

        ' move numbers to stack/array backwards
        For j = mNumbers.Length - 1 To 0 Step -1
            ReDim Preserve mNumberStack(i)

            mNumberStack(i) = mNumbers(j)
            i += 1
        Next

        For j = mNumbers.Length - 1 To 0 Step -1
            Select Case j
                Case 0, 3, 6, 9, 12
                    ' ones  value
                    If Not mOneTens Then
                        mNumWord &amp;amp;= GetOnes(Val(mNumberStack(j))) &amp;amp; Delimiter
                    End If

                    Select Case j
                        Case 3
                            ' thousands
                            mNumWord &amp;amp;= mPlaceValues(1) &amp;amp; Delimiter

                        Case 6
                            ' millions
                            mNumWord &amp;amp;= mPlaceValues(2) &amp;amp; Delimiter

                        Case 9
                            ' billions
                            mNumWord &amp;amp;= mPlaceValues(3) &amp;amp; Delimiter

                        Case 12
                            ' trillions
                            mNumWord &amp;amp;= mPlaceValues(4) &amp;amp; Delimiter
                    End Select


                Case Is = 1, 4, 7, 10, 13
                    ' tens value
                    If Val(mNumberStack(j)) = 0 Then
                        mNumWord &amp;amp;= GetOnes(Val(mNumberStack(j - 1))) &amp;amp; Delimiter
                        mOneTens = True
                        Exit Select
                    End If

                    If Val(mNumberStack(j)) = 1 Then
                        mNumWord &amp;amp;= mOneTensArray(Val(mNumberStack(j - 1))) &amp;amp; Delimiter
                        mOneTens = True
                        Exit Select
                    End If

                    mNumWord &amp;amp;= GetTens(Val(mNumberStack(j)))

                    ' this places the tensdelimiter; check for succeeding 0
                    If Val(mNumberStack(j - 1)) &amp;lt;&amp;gt; 0 Then
                        mNumWord &amp;amp;= TensDelimiter
                    End If
                    mOneTens = False

                Case Else
                    ' hundreds value 
                    mNumWord &amp;amp;= GetOnes(Val(mNumberStack(j))) &amp;amp; Delimiter

                    If Val(mNumberStack(j)) &amp;lt;&amp;gt; 0 Then
                        mNumWord &amp;amp;= mPlaceValues(0) &amp;amp; Delimiter
                    End If
            End Select
        Next

        Return mNumWord &amp;amp; mFraction

    End Function



End Class

'End Class
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/NYsWWd-jZ-U" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/NYsWWd-jZ-U/f6ec6753-8ba3-41a3-b113-ee8f5cc97553.aspx</link>
      <pubDate>Thu, 05 Jan 2012 05:56:46 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/f6ec6753-8ba3-41a3-b113-ee8f5cc97553.aspx</feedburner:origLink></item>
    <item>
      <title>Write text over image code</title>
      <description>Description: Just the basics of a class for writing text over an image.  About 90% complete.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/b8daaf77-eec6-42d6-a1c5-0983765a8ed0.aspx'&gt;http://www.codekeep.net/snippets/b8daaf77-eec6-42d6-a1c5-0983765a8ed0.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.IO

Public Class ImageTextWriter

    Public Enum TextColour
        Black
        White
    End Enum

    Public Enum vAlignment
        Top
        Middle
        Bottom
    End Enum

    Public Enum hAlignment
        Left
        Center
        Right
    End Enum

    Public Sub New()

    End Sub

    Public Shared Function OverlayText(ByVal ImageData() As Byte, ByVal Text As String, ByVal FontSize As Integer, ByVal Colour As TextColour, ByVal HorizontalAlignment As hAlignment, ByVal VerticalAlignment As vAlignment) As Byte()

        Dim sf As New StringFormat
        Dim padding As Integer = 5 'Drawing rectangle will be reduced by this much

        Select Case HorizontalAlignment
            Case hAlignment.Left
                sf.Alignment = StringAlignment.Near
            Case hAlignment.Right
                sf.Alignment = StringAlignment.Far
            Case hAlignment.Center
                sf.Alignment = StringAlignment.Center
        End Select

        Select Case VerticalAlignment
            Case vAlignment.Top
                sf.LineAlignment = StringAlignment.Near
            Case vAlignment.Middle
                sf.LineAlignment = StringAlignment.Center
            Case vAlignment.Bottom
                sf.LineAlignment = StringAlignment.Far
        End Select

        'Prepare a brush for the colour
        Dim b As SolidBrush

        Select Case Colour
            Case TextColour.Black
                b = New SolidBrush(Color.Black)
            Case TextColour.White
                b = New SolidBrush(Color.White)
        End Select

        Dim NewImage As Bitmap = New Bitmap(ConvertByteArrayToBitmap(ImageData))

        'Measure the size of the image for alignment of text
        Dim r As New Rectangle(New Point(padding, padding), NewImage.Size)

        r.Height = r.Height - padding
        r.Width = r.Width - padding

        'Prepare the graphics object
        Dim g As Graphics = Graphics.FromImage(NewImage)
        g.SmoothingMode = SmoothingMode.AntiAlias

        'Declare the font
        Dim f As New Font(&amp;quot;Arial&amp;quot;, FontSize, FontStyle.Regular)

        'Draw the text
        g.DrawString(Text, f, b, r, sf)

        Dim ms As New MemoryStream
        NewImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
        Dim output() As Byte
        output = ms.ToArray
        Return output

    End Function

    Public Shared Function ConvertByteArrayToBitmap(ByVal Input() As Byte) As Bitmap
        Dim ms As New MemoryStream
        ms.Write(Input, 0, Input.Length)
        Dim InputImage As New Bitmap(ms)
        Return InputImage
    End Function

    Public Shared Function ConvertBitmapToByteArray(ByVal Input As Bitmap) As Byte()
        Dim ms As New MemoryStream
        Input.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
        Dim output() As Byte
        output = ms.ToArray
        Return output
    End Function

End Class&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/JRu7xu3YeEA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/JRu7xu3YeEA/b8daaf77-eec6-42d6-a1c5-0983765a8ed0.aspx</link>
      <pubDate>Wed, 04 Jan 2012 11:00:57 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/b8daaf77-eec6-42d6-a1c5-0983765a8ed0.aspx</feedburner:origLink></item>
    <item>
      <title>Screen Resolution/ Change Form Size</title>
      <description>Description: Determine the screen resolution and change the form size&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/68582636-4b76-47a6-9396-36c977ad9ec7.aspx'&gt;http://www.codekeep.net/snippets/68582636-4b76-47a6-9396-36c977ad9ec7.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Dim ScreenWidth As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString()
        Dim ScreenHeight As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString()

        If ScreenHeight &amp;lt; 800 Then
            'Me.Size = New System.Drawing.Size(1200, 900) '1667, 1196
            If r.IsManager = True And r.SalesRegion &amp;lt;&amp;gt; &amp;quot;FP&amp;quot; Then
                MessageBox.Show(&amp;quot;Your ScreenWidth is: &amp;quot; + ScreenWidth + &amp;quot; x &amp;quot; + ScreenHeight &amp;amp; &amp;quot;. This size screen will not accomodate the charts. You must change your screen resolution manually to see the charts properly.&amp;quot;)
                'pnl_Manager.Size = New System.Drawing.Size(1190, 700) '1642, 966
                'StagePercViewer.Size = New System.Drawing.Size(500, 250) '889, 450
                'PipelinePercViewer.Size = New System.Drawing.Size(300, 150) '505, 450
                'LostPercViewer.Size = New System.Drawing.Size(1190, 700) '793, 465
                'WonPercViewer.Size = New System.Drawing.Size(1190, 700) '833, 465
            End If
        End If&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/Dlh1bXXpuwI" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/Dlh1bXXpuwI/68582636-4b76-47a6-9396-36c977ad9ec7.aspx</link>
      <pubDate>Thu, 29 Dec 2011 17:07:04 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/68582636-4b76-47a6-9396-36c977ad9ec7.aspx</feedburner:origLink></item>
    <item>
      <title>IsNumeric in WHERE statement for MS Access</title>
      <description>Description: Using IsNumeric as the WHERE statment to return only numbers&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/5f1ede43-58c6-4bec-a749-3b5dd1b7e366.aspx'&gt;http://www.codekeep.net/snippets/5f1ede43-58c6-4bec-a749-3b5dd1b7e366.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt; Public Function FindAllOriginals() As InvoiceCustomerCollection
        Dim tbl As New DataTable

        Using conn As New OleDbConnection(getMoverStr())
            conn.Open()
            Dim cmd As OleDbCommand = conn.CreateCommand

            cmd.CommandText = &amp;quot;SELECT Invoice.notes, Invoice.exported, Invoice.invoiceNum, Invoice.registrationNum, Invoice.invoiceDate, &amp;quot; _
            &amp;amp; &amp;quot; Shipment.firstName, Shipment.lastName FROM Customer INNER JOIN (Invoice INNER JOIN Shipment ON Invoice.registrationNum = Shipment.registrationNum) &amp;quot; _
            &amp;amp; &amp;quot; ON Customer.customerID = Shipment.customerID WHERE (IsNumeric([Invoice.invoiceNum]))&amp;quot;

            Dim reader As OleDb.OleDbDataReader = cmd.ExecuteReader
            tbl.Load(reader)
        End Using

        Return MapDataToInvoiceCustomer(tbl)

    End Function&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepVBNET/~4/m_tfD1HB0tU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepVBNET/~3/m_tfD1HB0tU/5f1ede43-58c6-4bec-a749-3b5dd1b7e366.aspx</link>
      <pubDate>Fri, 23 Dec 2011 18:04:53 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/5f1ede43-58c6-4bec-a749-3b5dd1b7e366.aspx</feedburner:origLink></item>
  </channel>
</rss>

