Saturday, 12 September 2015

Hello Every one

We at Elite Software Solutions provide you the best unique codes snippets for all your needs
get your projects done in a week from experts.

OUR SERVICES ARE AS FOLLOWS

Web Designing
Web Promotion
.Net Developing(C#,Vb,ASP)
 
Facebook LIKES Sales (get 10K likes to your Facebook page in a single day at low prices)
Facebook group advertising- Get your product advertised in 1000's of groups
Blog Creations- 0.2 millions blogs and counting
Blog advertising.

and lastly the new way of getting noticed

Online Event Organisation
Online Event managing and promotion 

Contact us at
ss.sachin750@gmail.com


Start Your vb.net app from Windows Notification area

Start Your vb.net app from Windows Notification area


Imports System.Net.Mail
Public Class Form2
    Dim y As Integer
    Dim x As Integer
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Hide()
        Me.Notif.Visible = True
        draw()
        Me.ShowInTaskbar = False

        Timer3.Enabled = True
        Me.Hide()
        ' Timer1_Tick(Nothing, Nothing)
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Show()
        Me.Top = Me.Top - 10
        If Me.Top < y - Me.Height Then
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        Timer2.Enabled = True
        'Hide()
        'Me.Notif.Visible = True
        'Me.ShowInTaskbar = False

        'Timer3.Enabled = True
        'Me.Hide()
        '' Timer1_Tick(Nothing, Nothing)
        'Me.WindowState = FormWindowState.Minimized
    End Sub

    Sub draw()
        Dim sx As Integer
        Dim sy As Integer
        sx = My.Computer.Screen.Bounds.Width
        sy = My.Computer.Screen.Bounds.Height
        x = sx - Me.Width
        y = sy - 0
        Me.Left = x - 0
        Me.Top = y
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Me.Top = Me.Top + 10
        Do Until Me.Top > 768
            Me.Top = Me.Top + 10
        Loop
        If Me.Top > y Then
            Timer2.Enabled = False
            ' Timer2.Enabled = True
        End If
        If Me.Top = 728 Then
            Timer2.Enabled = False
            Hide()
            Me.Top = 728
            Exit Sub
        End If
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub

    Private Sub Notif_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Notif.MouseDoubleClick
        Timer1.Enabled = True
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Me.Show()
        Timer3.Enabled = False
        ' fhide()
        If Timer3.Enabled = False Then
            Timer1.Enabled = True
        End If
    End Sub
End Class

File watcher in vb.net

File watcher in vb.net
choose path and any changes to the drive like creation deletion of files will be recorded

Try it




Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        FolderBrowserDialog1.ShowDialog()
        TextBox1.Text = FolderBrowserDialog1.SelectedPath
        FileSystemWatcher1.Path = TextBox1.Text
        MsgBox("Path to monitor is now set to: " & TextBox1.Text)
    End Sub
    Private Sub FileSystemWatcher1_Renamed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Renamed
        ListBox1.Items.Add("File- " & e.FullPath.ToString & " renamed at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
        ListBox2.Items.Add("File- " & e.FullPath.ToString & " created at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Deleted
        ListBox3.Items.Add("File- " & e.FullPath.ToString & " deleted at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
        ListBox4.Items.Add("File- " & e.FullPath.ToString & " modified at: " & System.DateTime.Now)
    End Sub

End Class

Document/File Browser in vb.net

Document/File Browser in vb.net
Imports System.IO
Public Class Form25
    Dim k, k1 As String
    Private Sub Form25_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub




    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
        MyFolderBrowser.Description = "Please Select the Folder Containing Database Files"
        MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyComputer
        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
        If dlgResult = Windows.Forms.DialogResult.OK Then
            TextBox2.Text = MyFolderBrowser.SelectedPath
         
        End If


    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim a As String
     
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()
        ListBox3.Items.Clear()
        ListBox4.Items.Clear()
        Dim d As String = TextBox2.Text & "\"
        If System.IO.Directory.Exists(TextBox2.Text) Then
            For Each Dir As String In Directory.GetDirectories(TextBox2.Text)
                ListBox1.Items.Add(Replace(Dir, d, ""))
            Next

        Else
            MsgBox("Invalid Directory")
            TextBox2.Text = ""
            Exit Sub
        End If
     
        Dim di As New IO.DirectoryInfo(TextBox2.Text)
        Dim diar1 As IO.FileInfo() = di.GetFiles("*.*")

        Dim dra As IO.FileInfo

        Dim count = 0
        For Each dra In diar1
            ListBox2.Items.Add(dra)
            a = dra.Extension
            If a = ".mdf" Or a = ".LDF" Then
                ListBox4.Items.Add("Database Files")
            ElseIf a = ".docx" Or a = ".rtf" Then
                ListBox4.Items.Add("Word Files")
                ListBox3.Items.Add(dra)
            ElseIf a = ".xlsx" Then
                ListBox4.Items.Add("Speed Sheet Files")
                ListBox3.Items.Add(dra)
            ElseIf a = ".pdf" Or a = ".xps" Then
                ListBox4.Items.Add("Printing Files")
                ListBox3.Items.Add(dra)
            Else
                ListBox4.Items.Add("Other Files")
            End If
            count = count + 1
        Next

    End Sub

    Private Sub ListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Click
        If TextBox2.Text.Length < 5 Then
            TextBox2.Text = Nothing
        End If
        If TextBox2.Text = Nothing Then
            TextBox2.Text = ListBox1.Text
        Else
            TextBox2.Text = TextBox2.Text & "\" & ListBox1.Text
        End If

    
    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox2.Text = Nothing
    End Sub

 
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If TextBox2.Text.Length = 0 Then
            MsgBox("Search String is empty")
            Exit Sub
        End If
        k = StrReverse(TextBox2.Text)
        Dim test As String = k
        Dim slen As Integer = TextBox2.Text.Length
        Dim startPos As Integer = test.IndexOf("_") + 1
        Dim endPos As Integer = test.IndexOf("\", startPos)
        Dim result As String = test.Substring(startPos, endPos - startPos)
        k1 = "\" & StrReverse(result)
        If TextBox2.Text = "" Then
            MsgBox("please choose a directory to Search")
        Else
            ' TextBox2.Text = Replace(slen, endPos + 1, "")
            TextBox2.Text = Replace(TextBox2.Text, k1, "")
        End If
    End Sub
End Class

Windows similar Image Viewer and Image Mover in VB.NET

Windows similar Image Viewer and Image Mover in VB.NET



Code:(path image in Form Load must be changed to folder containing pictures)

Public Class Form20
    Dim a, b As Integer
    Private m_PanStartPoint As New Point

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Panel1.AutoScroll = True
        pb1.SizeMode = PictureBoxSizeMode.AutoSize
        ListBox1.Items.Clear()
        Dim di As New IO.DirectoryInfo(pathimage)
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo
        Dim count = 0
        For Each dra In diar1
            ListBox1.Items.Add(dra)
            count = count + 1
        Next
        TextBox1.Text = count
    End Sub

    Private Sub pb1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pb1.MouseDown
        m_PanStartPoint = New Point(e.X, e.Y)
    End Sub

    Private Sub pb1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pb1.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            'Here we get the change in coordinates.
            'We multiply it by -1 because of how the panels autoscroll works.
            Dim DeltaX As Integer = (m_PanStartPoint.X - e.X)
            Dim DeltaY As Integer = (m_PanStartPoint.Y - e.Y)
            'Set the new autoscroll position.
            'ALWAYS pass positive integers to the panels autoScrollPosition method
            Panel1.AutoScrollPosition = New Drawing.Point((DeltaX - Panel1.AutoScrollPosition.X), (DeltaY - Panel1.AutoScrollPosition.Y))
        End If
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        pb1.ImageLocation = pathimage & "\" & ListBox1.Text
        PictureBox1.ImageLocation = pathimage & "\" & ListBox1.Text
    End Sub


  


    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.Normal
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.Visible = True
        a = PictureBox1.Location.X
        b = PictureBox1.Location.Y
        pb1.Visible = False
        Panel1.Visible = False
        PictureBox1.Size = Panel1.Size
        PictureBox1.Location = Panel1.Location
        RadioButton1.Visible = True
        RadioButton2.Visible = True
        RadioButton3.Visible = True
        RadioButton4.Visible = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        pb1.Visible = True
        Panel1.Visible = True
        PictureBox1.Location = New Point(a, b)
        PictureBox1.Size = New Point(143, 12)
        PictureBox1.Visible = False
        RadioButton1.Visible = False
        RadioButton2.Visible = False
        RadioButton3.Visible = False
        RadioButton4.Visible = False
    End Sub
End Class

Slideshow In VB.net with time intervals

Slideshow In VB.net

Imports System.IO
Public Class SlideShow
    Dim c As String
    Dim i As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As String
        Dim b As String = "\bin\Debug"
        a = Directory.GetCurrentDirectory
        c = Replace(a, b, "")
        ComboBox1.Items.Add("1")
        ComboBox1.Items.Add("2")
        ComboBox1.Items.Add("3")
        ComboBox1.Items.Add("5")
        ComboBox1.Items.Add("10")

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        PictureBox1.ImageLocation = TextBox1.Text & "\" & ListBox1.Text
        TextBox2.Text = ListBox1.SelectedIndex
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Me.WindowState = FormWindowState.Maximized
        'PictureBox1.Size = Me.Size
        i = ListBox1.Items.Count
        Timer1.Enabled = True

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim k As Integer
        If TextBox2.Text = "" Then
            i = 0
        Else
            i = TextBox2.Text
        End If
        If ListBox1.Items.Count <> 0 Then
            While i <= ListBox1.Items.Count - 1
                i = i + 1
                If i = ListBox1.Items.Count Then
                    i = 0
                End If
                ListBox1.SelectedIndex = i
                PictureBox1.ImageLocation = TextBox1.Text & "\" & ListBox1.Text
                PictureBox2.ImageLocation = TextBox1.Text & "\" & ListBox1.Text
                Exit Sub
            End While
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.WindowState = FormWindowState.Maximized
        PictureBox2.Visible = True
        PictureBox2.Height = 683
        PictureBox2.Width = 1019
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Timer1.Enabled = False

    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Timer1.Enabled = True
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        PictureBox2.Visible = False
        PictureBox2.Height = 10
        PictureBox2.Width = 50
        Me.WindowState = FormWindowState.Normal
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
        MyFolderBrowser.Description = "Please Select the Folder Containing Database Files"
        MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyComputer
        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
        If dlgResult = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = MyFolderBrowser.SelectedPath

        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        ListBox1.Items.Clear()
        Dim di As New IO.DirectoryInfo(TextBox1.Text)
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo

        Dim count As Integer = 0
        For Each dra In diar1
            ListBox1.Items.Add(dra)
            count = count + 1
        Next
        TextBox3.Text = count
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Timer1.Enabled = False
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Timer1.Enabled = True
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Timer1.Interval = Val(ComboBox1.Text) * 1000
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        ListBox1.Items.Clear()
    End Sub
End Class


Read MS Word And Excel Files From Vb.net

Read MS Word And Excel Files From Vb.net

Copy and Paste the Code In the Code Window :

Imports Word = Microsoft.Office.Interop.Word
Imports System.Runtime.InteropServices
Imports System
Imports System.Data
Imports System.Data.Odbc
Imports System.Data.OleDb
Public Class ImportDoc
    Dim MSWord As New Word.Application
    Dim WordDoc As New Word.Document
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Title = "Please select a MicroSoft Word file"
        OpenFileDialog1.InitialDirectory = docpath
        OpenFileDialog1.Filter = "Word files (*.doc)|*.docx"
        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Dim wordFileName As String = OpenFileDialog1.FileName
            TextBox1.Text = wordFileName
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        OpenFileDialog1.FileName = TextBox1.Text
        With MSWord
            .Documents.Open(OpenFileDialog1.FileName)
            .Selection.WholeStory()
            .Selection.Copy()
            RichTextBox1.Paste()
            .Quit()
        End With
        MSWord = Nothing
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Using f As New Form1
        'f.ShowDialog()
        ' f.Dispose()
        ' End Using
        Dim dt As New DataTable
        Dim OpenFileDialog1 As New OpenFileDialog
        Dim FileName As String = ""
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = OpenFileDialog1.FileName.ToUpper
            Dim Builder As New OleDbConnectionStringBuilder With {.DataSource = FileName}
            TextBox1.Text = OpenFileDialog1.FileName
            OpenFileDialog1.Filter = "Excel files (*.xlsx)|*.xlsx"
            If IO.Path.GetExtension(FileName.ToUpper) = ".XLSX" Then
                Builder.Provider = "Microsoft.ACE.OLEDB.12.0"
                Builder.Add("Extended Properties", "Excel 12.0;HDR=No;")
            Else
                Builder.Provider = "Microsoft.Jet.OLEDB.4.0"
                Builder.Add("Extended Properties", "Excel 8.0;HDR=No;")
            End If
            Using cn As New OleDbConnection With {.ConnectionString = Builder.ConnectionString}
                Dim cmd As New OleDbCommand With _
                { _
                    .CommandText = "SELECT * FROM [Sheet1$]", _
                    .Connection = cn _
                }
                cn.Open()
                dt.Load(cmd.ExecuteReader)
            End Using
            DataGridView1.DataSource = Nothing
            If dt.Rows.Count > 0 Then
                DataGridView1.DataSource = dt
            Else
                MessageBox.Show(String.Format("Did not find any data in{0}{1}", Environment.NewLine, FileName))
            End If
        End If
    End Sub
  
 


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        RichTextBox1.Visible = True
        DataGridView1.Visible = False
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        RichTextBox1.Visible = False
        DataGridView1.Visible = True
    End Sub
End Class


Send Email With attachment

Send Email With attachment
Imports System.Net.Mail
Imports System.Net

Public Class Mailss
    Dim oMsg As Mail.MailMessage = New MailMessage()
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            TextBox6.Visible = True
        Else
            TextBox6.Visible = False
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label6.Visible = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Title = "Please select a file"
        OpenFileDialog1.InitialDirectory = "C:"
        OpenFileDialog1.Filter = "All files (*.*)|*.*"
        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Dim wordFileName As String = OpenFileDialog1.FileName
            TextBox6.Text = wordFileName
        End If
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Mail As New MailMessage
        If (TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "") Then
            MsgBox("Please enter a valid e-mail")
        Else
            Mail.Subject = TextBox5.Text
            Mail.To.Add(TextBox3.Text)
            Mail.From = New MailAddress(TextBox3.Text)
            Mail.Body = TextBox4.Text
            Dim oAttch As Mail.Attachment = New Mail.Attachment(TextBox6.Text)
            Mail.Attachments.Add(oAttch)
            Dim smtp As New SmtpClient("Smtp.gmail.com")
            smtp.EnableSsl = True
            smtp.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
            smtp.Port = "587"
            smtp.Send(Mail)
            Label6.Visible = True
            Timer1.Enabled = True
        End If
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
    End Sub
End Class

Convert Excel File To XPS and PDF

Convert Excel File To XPS and PDF

Imports Microsoft.Office.Interop.Excel
Public Class XlscDoc
    Dim oXL As Application
    Dim oWB As Workbook
    Dim oSheet As Worksheet
    Dim oRng As Range
    Dim path As String
    Dim path1 As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        ' If either required string is null or empty, stop and bail out
        If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
            MsgBox("Path Empty")
        End If

        ' Create COM Objects
        Dim excelApplication As Microsoft.Office.Interop.Excel.Application
        Dim excelWorkbook As Microsoft.Office.Interop.Excel.Workbook

        ' Create new instance of Excel
        excelApplication = New Microsoft.Office.Interop.Excel.Application()

        ' Make the process invisible to the user
        excelApplication.ScreenUpdating = False

        ' Make the process silent
        excelApplication.DisplayAlerts = False

        ' Open the workbook that you wish to export to PDF
        excelWorkbook = excelApplication.Workbooks.Open(TextBox1.Text)

        ' If the workbook failed to open, stop, clean up, and bail out
        If excelWorkbook Is Nothing Then
            excelApplication.Quit()

            excelApplication = Nothing
            excelWorkbook = Nothing

            MsgBox("Path Empty")
        End If

        Dim exportSuccessful = True
        Dim a As String
        a = TextBox2.Text & "\" & TextBox3.Text & ".pdf"
        Try
            ' Call Excel's native export function (valid in Office 2007 and Office 2010, AFAIK)
            excelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, a)
        Catch ex As System.Exception
            ' Mark the export as failed for the return value...

            ' Do something with any exceptions here, if you wish...
            ' MessageBox.Show...       
            exportSuccessful = False
        Finally
            ' Close the workbook, quit the Excel, and clean up regardless of the results...
            excelWorkbook.Close()
            excelApplication.Quit()

            excelApplication = Nothing
            excelWorkbook = Nothing
        End Try

        ' You can use the following method to automatically open the PDF after export if you wish
        ' Make sure that the file actually exists first...
        If System.IO.File.Exists(TextBox2.Text) Then
            System.Diagnostics.Process.Start(TextBox2.Text)
        End If
        MsgBox("Export succesful")
    End Sub

    Private Sub XlscDoc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        path = docpath
        TextBox1.Text = path
        path1 = pdfpath
        TextBox2.Text = path1
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim d As String
        Dim f As String
        OpenFileDialog1.Title = "Please select a MicroSoft Excel file"
        OpenFileDialog1.InitialDirectory = docpath
        OpenFileDialog1.Filter = "Word files (*.xls)|*.xls"
        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Dim wordFileName As String = OpenFileDialog1.FileName
            TextBox1.Text = wordFileName
        End If
        d = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
        f = ".xlsx"
        TextBox3.Text = Replace(d, f, "")
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        FolderBrowserDialog1.ShowDialog()
        TextBox2.Text = FolderBrowserDialog1.SelectedPath
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If String.IsNullOrEmpty(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox2.Text) Then
            MsgBox("Path Empty")
        End If

        ' Create COM Objects
        Dim excelApplication As Microsoft.Office.Interop.Excel.Application
        Dim excelWorkbook As Microsoft.Office.Interop.Excel.Workbook

        ' Create new instance of Excel
        excelApplication = New Microsoft.Office.Interop.Excel.Application()

        ' Make the process invisible to the user
        excelApplication.ScreenUpdating = False

        ' Make the process silent
        excelApplication.DisplayAlerts = False

        ' Open the workbook that you wish to export to PDF
        excelWorkbook = excelApplication.Workbooks.Open(TextBox1.Text)

        ' If the workbook failed to open, stop, clean up, and bail out
        If excelWorkbook Is Nothing Then
            excelApplication.Quit()

            excelApplication = Nothing
            excelWorkbook = Nothing

            MsgBox("Path Empty")
        End If

        Dim exportSuccessful = True
        Dim a As String
        a = TextBox2.Text & "\" & TextBox3.Text & ".xps"
        Try
            ' Call Excel's native export function (valid in Office 2007 and Office 2010, AFAIK)
            excelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypeXPS, a)
        Catch ex As System.Exception
            ' Mark the export as failed for the return value...

            ' Do something with any exceptions here, if you wish...
            ' MessageBox.Show...       
            exportSuccessful = False
        Finally
            ' Close the workbook, quit the Excel, and clean up regardless of the results...
            excelWorkbook.Close()
            excelApplication.Quit()

            excelApplication = Nothing
            excelWorkbook = Nothing
        End Try

        ' You can use the following method to automatically open the PDF after export if you wish
        ' Make sure that the file actually exists first...
        If System.IO.File.Exists(TextBox2.Text) Then
            System.Diagnostics.Process.Start(TextBox2.Text)
        End If
        MsgBox("Export succesful")
    End Sub
End Class
 

Type In RichTextBox and Save as MS WORD file

Type In RichTextBox and Save as MS WORD file
Coding:

Imports Microsoft.Office.Interop.Word
Public Class RTB2MSWord
    Dim Word As Microsoft.Office.Interop.Word.Application
    Private Sub RTB2MSWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Word = New Microsoft.Office.Interop.Word.Application
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim app As New Microsoft.Office.Interop.Word.Application()
        'app.Visible = True
        Dim tempOutputPath As Object = "E:\Zoo Management\Zoo Management\Documents\" & TextBox1.Text & ".rtf"
        RichTextBox1.SaveFile(DirectCast(tempOutputPath, String))
        Dim typeMissing As Object = Type.Missing
        Dim trueIndicator As Object = True
        app.Documents.Open(tempOutputPath, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, typeMissing, trueIndicator, typeMissing, typeMissing, typeMissing, typeMissing)
        app.Quit()
        MsgBox("Export Complete")
    End Sub
End Class

Export Sql Tables in Excel Spread Sheet Format For Mailing

Export Sql Tables in Excel Spread Sheet Format For Mailing
Coding::

Imports System.Data.SqlClient
Imports System.IO.File
Imports System.IO.Compression

Public Class ExportExcel
    Dim dt As New DataTable
    Dim ds As New DataSet
    Dim da As SqlDataAdapter
    Dim rs As SqlDataReader
    Dim conn As New SqlConnection
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox2.Text = docpath


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            MsgBox("Please Enter A File Name To Save")
            Exit Sub
        End If
        If TextBox2.Text = "" Then
            MsgBox("Please Select Path to Save the File")
            Exit Sub
        End If
        Dim attribute As System.IO.FileAttributes = FileAttribute.ReadOnly


        TextBox3.Text = TextBox2.Text & "\" & TextBox1.Text & ".xlsx"
        Dim xlApp As Microsoft.Office.Interop.Excel.Application
        Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
        Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value
        Dim i As Integer
        Dim j As Integer

        xlApp = New Microsoft.Office.Interop.Excel.Application
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = xlWorkBook.Sheets("sheet1")


        For i = 0 To DataGridView1.RowCount - 2
            For j = 0 To DataGridView1.ColumnCount - 1
                For k As Integer = 1 To DataGridView1.Columns.Count
                    xlWorkSheet.Cells(1, k) = DataGridView1.Columns(k - 1).HeaderText
                    xlWorkSheet.Cells(i + 2, j + 1) = DataGridView1(j, i).Value.ToString()
                Next
            Next
        Next

        xlWorkSheet.SaveAs(TextBox3.Text)
        xlWorkBook.Close()
        xlApp.Quit()

        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)
        System.IO.File.SetAttributes(TextBox3.Text, attribute)
        MsgBox("You can find the file at " & TextBox3.Text)
    End Sub

    Private Sub releaseObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        Finally
            GC.Collect()
        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.Items.Clear()
        Dim conn As New SqlConnection
        Dim cmd As New SqlCommand
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        Dim dt As New DataTable
        Dim i As Integer
        Dim n As Integer
        Dim len As Integer
        Dim dd As String = TextBox6.Text
        Dim cc As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & TextBox5.Text & ";Integrated Security=True;Connect Timeout=30;User Instance=True"
        conn.ConnectionString = cc
        'conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Sachin\Desktop\projects\Export Excel\Export Excel\Zoo.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
        conn.Open()
        cmd.Connection = conn
        cmd.CommandText = "select * from INFORMATION_SCHEMA.tables"
        da = New SqlDataAdapter(cmd.CommandText, conn)
        da.Fill(ds, dd)
        len = da.Fill(ds, dd)
        While i <= len - 1
            ListBox1.Items.Add(ds.Tables(dd).Rows(i).Item(2))
            i = i + 1
            n = n + 1
        End While
        conn.Close()
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        DataGridView1.Refresh()
        'dt.AcceptChanges()
        Dim cc As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & TextBox5.Text & ";Integrated Security=True;Connect Timeout=30;User Instance=True"
        conn.ConnectionString = cc
        conn.Open()
        TextBox4.Text = ListBox1.SelectedItem.ToString
        TextBox1.Text = TextBox4.Text
        'ds.Reset()
        dt = New DataTable
        ds.Tables.Add(dt)
        da = New SqlDataAdapter("select * from " & TextBox4.Text & " ", conn)
        da.Fill(dt)
        DataGridView1.DataSource = dt.DefaultView   '.   WriteXmlSchema  dt.DefaultView
        conn.Close()

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim i As Integer
        For i = 0 To DataGridView1.Columns.Count - 1
            DataGridView1.Columns.Remove(DataGridView1.Columns(0).Name)
        Next
        dt = Nothing
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        OpenFileDialog1.Title = "Please Select a Database File"
        OpenFileDialog1.InitialDirectory = "C:"
        OpenFileDialog1.Filter = "Database Files (*.mdf)|*.mdf"
        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Dim db As String
            db = OpenFileDialog1.FileName
            TextBox5.Text = db
            TextBox6.Text = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
        End If
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox5.Text = dbpath
        Dim di As New IO.DirectoryInfo(TextBox5.Text)
        Dim diar1 As IO.FileInfo() = di.GetFiles("*.mdf")

        Dim dra As IO.FileInfo

        Dim count = 0
        For Each dra In diar1
            ListBox2.Items.Add(dra)
            count = count + 1
        Next

    End Sub

    Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
        TextBox5.Text = TextBox5.Text & "\" & ListBox2.SelectedItem.ToString
        TextBox6.Text = ListBox2.SelectedItem.ToString
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
        MyFolderBrowser.Description = "Please Select the Folder Containing Database Files"
        MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyComputer
        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
        If dlgResult = Windows.Forms.DialogResult.OK Then
            TextBox2.Text = MyFolderBrowser.SelectedPath
        End If
    End Sub
End Class
 


Read Excel Spread Sheets From VB.Net

Read Excel Spread Sheets From VB.Net
Code :

Imports System.Data.OleDb
Imports System.IO

Public Class Form1

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim conn As OleDbConnection

        Dim dta As OleDbDataAdapter

        Dim dts As DataSet
        Dim excel As String
        Dim OpenFileDialog As New OpenFileDialog

        OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        OpenFileDialog.Filter = "All Files (*.*)|*.*|Excel files (*.xlsx)|*.xlsx|CSV Files (*.csv)|*.csv|XLS Files (*.xls)|*xls"

        If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then

            Dim fi As New FileInfo(OpenFileDialog.FileName)
            Dim FileName As String = OpenFileDialog.FileName

            excel = fi.FullName
            conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties=Excel 12.0;")
            dta = New OleDbDataAdapter("Select * From [Sheet1$]", conn)
            dts = New DataSet
            dta.Fill(dts, "[Sheet1$]")
            DataGridView1.DataSource = dts
            DataGridView1.DataMember = "[Sheet1$]"
            conn.Close()
        End If
    End Sub
End Class



Send Email From VB.net

Send Email From VB.net (Internet Connection Required)
Copy the code and Paste in Code Window:

Imports System.Net.Mail
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mail As New MailMessage
        If (TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "") Then
            MsgBox("Please enter a valid e-mail")
        Else
            mail.Subject = "email"
            mail.To.Add(TextBox3.Text)
            mail.From = New MailAddress(TextBox3.Text)
            mail.Body = TextBox4.Text
            MsgBox("mail sent")

            Dim smtp As New SmtpClient("Smtp.gmail.com")
            smtp.EnableSsl = True
            smtp.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
            smtp.Port = "587"
            smtp.Send(mail)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class


Download File with Progress

Download File with Progress

Coding :

Imports System.Net
Public Class mainForm

    Dim whereToSave As String 'Where the program save the file

    Delegate Sub ChangeTextsSafe(ByVal length As Long, ByVal position As Integer, ByVal percent As Integer, ByVal speed As Double)
    Delegate Sub DownloadCompleteSafe(ByVal cancelled As Boolean)

    Public Sub DownloadComplete(ByVal cancelled As Boolean)
        Me.txtFileName.Enabled = True
        Me.btnDownload.Enabled = True
        Me.btnCancel.Enabled = False

        If cancelled Then

            Me.Label4.Text = "Cancelled"

            MessageBox.Show("Download aborted", "Aborted", MessageBoxButtons.OK, MessageBoxIcon.Information)


        Else
            Me.Label4.Text = "Successfully downloaded"

            MessageBox.Show("Successfully downloaded!", "All OK", MessageBoxButtons.OK, MessageBoxIcon.Information)


        End If

        Me.ProgressBar1.Value = 0
        Me.Label5.Text = "Downloading: "
        Me.Label6.Text = "Save to: "
        Me.Label3.Text = "File size: "
        Me.Label2.Text = "Download speed: "
        Me.Label4.Text = ""

    End Sub

    Public Sub ChangeTexts(ByVal length As Long, ByVal position As Integer, ByVal percent As Integer, ByVal speed As Double)

        Me.Label3.Text = "File Size: " & Math.Round((length / 1024), 2) & " KB"

        Me.Label5.Text = "Downloading: " & Me.txtFileName.Text

        Me.Label4.Text = "Downloaded " & Math.Round((position / 1024), 2) & " KB of " & Math.Round((length / 1024), 2) & "KB (" & Me.ProgressBar1.Value & "%)"

        If speed = -1 Then
            Me.Label2.Text = "Speed: calculating..."
        Else
            Me.Label2.Text = "Speed: " & Math.Round((speed / 1024), 2) & " KB/s"
        End If

        Me.ProgressBar1.Value = percent


    End Sub

    Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click

        If Me.txtFileName.Text <> "" AndAlso Me.txtFileName.Text.StartsWith("http://") Then


            Me.SaveFileDialog1.FileName = TextBox1.Text

            If Me.SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

                Me.whereToSave = Me.SaveFileDialog1.FileName

                Me.SaveFileDialog1.FileName = ""

                Me.Label6.Text = "Save to: " & Me.whereToSave

                Me.txtFileName.Enabled = False
                Me.btnDownload.Enabled = False
                Me.btnCancel.Enabled = True

                Me.BackgroundWorker1.RunWorkerAsync() 'Start download

            End If

        Else

            MessageBox.Show("Please insert valid URL for download", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)

        End If

    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

        'Creating the request and getting the response
        Dim theResponse As HttpWebResponse
        Dim theRequest As HttpWebRequest
        Try 'Checks if the file exist

            theRequest = WebRequest.Create(Me.txtFileName.Text)
            theResponse = theRequest.GetResponse
        Catch ex As Exception

            MessageBox.Show("An error occurred while downloading file. Possibe causes:" & ControlChars.CrLf & _
                            "1) File doesn't exist" & ControlChars.CrLf & _
                            "2) Remote server error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            Dim cancelDelegate As New DownloadCompleteSafe(AddressOf DownloadComplete)

            Me.Invoke(cancelDelegate, True)

            Exit Sub
        End Try
        Dim length As Long = theResponse.ContentLength 'Size of the response (in bytes)

        Dim safedelegate As New ChangeTextsSafe(AddressOf ChangeTexts)
        Me.Invoke(safedelegate, length, 0, 0, 0) 'Invoke the TreadsafeDelegate

        Dim writeStream As New IO.FileStream(Me.whereToSave, IO.FileMode.Create)

        'Replacement for Stream.Position (webResponse stream doesn't support seek)
        Dim nRead As Integer

        'To calculate the download speed
        Dim speedtimer As New Stopwatch
        Dim currentspeed As Double = -1
        Dim readings As Integer = 0

        Do

            If BackgroundWorker1.CancellationPending Then 'If user abort download
                Exit Do
            End If

            speedtimer.Start()

            Dim readBytes(4095) As Byte
            Dim bytesread As Integer = theResponse.GetResponseStream.Read(readBytes, 0, 4096)

            nRead += bytesread
            Dim percent As Short = (nRead * 100) / length

            Me.Invoke(safedelegate, length, nRead, percent, currentspeed)

            If bytesread = 0 Then Exit Do

            writeStream.Write(readBytes, 0, bytesread)

            speedtimer.Stop()

            readings += 1
            If readings >= 5 Then 'For increase precision, the speed it's calculated only every five cicles
                currentspeed = 20480 / (speedtimer.ElapsedMilliseconds / 1000)
                speedtimer.Reset()
                readings = 0
            End If
        Loop

        'Close the streams
        theResponse.GetResponseStream.Close()
        writeStream.Close()

        If Me.BackgroundWorker1.CancellationPending Then

            IO.File.Delete(Me.whereToSave)

            Dim cancelDelegate As New DownloadCompleteSafe(AddressOf DownloadComplete)

            Me.Invoke(cancelDelegate, True)

            Exit Sub

        End If

        Dim completeDelegate As New DownloadCompleteSafe(AddressOf DownloadComplete)

        Me.Invoke(completeDelegate, False)

    End Sub

    Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Label4.Text = ""
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.BackgroundWorker1.CancelAsync() 'Send cancel request
    End Sub

  
End Class


Download A List Of files

Download A List Of files
Code:

Imports System.Net
Public Class Form1
    Private WithEvents HttpClient As WebClient
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
        ListBox2.Items.Add(TextBox2.Text)
        TextBox1.Clear()
        TextBox2.Clear()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        SaveFileDialog1.ShowDialog()
        TextBox2.Text = SaveFileDialog1.FileName
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim theResponse As HttpWebResponse
        Dim theRequest As HttpWebRequest
        Dim length As Long
        Try
          
            HttpClient = New WebClient
            Dim total As Integer = ListBox1.Items.Count
            Dim current As Integer = -1
            While current < total
                ListBox1.SelectedIndex = current + 1
                ListBox2.SelectedIndex = current + 1
                Dim down As String = ListBox1.SelectedItem
                Dim add As String = ListBox2.SelectedItem
                theRequest = WebRequest.Create(Me.ListBox1.SelectedItem)
                theResponse = theRequest.GetResponse
                length = theResponse.ContentLength
                Label5.Text = "Length = " & (length / 1024) & "Bytes"
                HttpClient.DownloadFileAsync(New Uri(down), add)
                ' Label3.Text = HttpClient.DownloadFile((down), add)
                Label3.Text = "Current Status : Downloading"
                Do While HttpClient.IsBusy
                    Application.DoEvents()
                Loop
                current = current + 1
            End While
        Catch ex As Exception
            'ListBox1.Items.Clear()
            'ListBox2.Items.Clear()
        End Try
      
        'Checks if the file exist

        ' theRequest = WebRequest.Create(Me.ListBox1.SelectedItem)
        ' theResponse = theRequest.GetResponse
        ' Dim length As Long = theResponse.ContentLength
        'Label5.Text = "Length = " & length


    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        HttpClient.CancelAsync()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        HttpClient.CancelAsync()
        Me.Close()
    End Sub

    Private Sub HttpClient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles HttpClient.DownloadProgressChanged
        ProgressBar1.Maximum = e.TotalBytesToReceive
        ProgressBar1.Value = e.BytesReceived
        Label4.Text = "Downloaded" & e.ProgressPercentage
        If e.ProgressPercentage = 100 Then
            Label3.Text = "download complete"
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Label6.Text = "Downloaded " & Me.ProgressBar1.Value & "%"
    End Sub
End Class