Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim url As String = checkURL() Try Dim fo As New SaveFileDialog fo.Filter = "Executable File|.exe|All Files|*" fo.FilterIndex = 1 fo.RestoreDirectory = True fo.ShowDialog() Dim path As String = fo.FileName My.Computer.Network.DownloadFile(url, path) MsgBox("Finished!") Catch ex As Exception MsgBox("Failed") End Try End Sub
Private Function checkURL() Dim s As String = TextBox1.Text.ToLower() If (s.StartsWith("http://www.") Or s.StartsWith("https://www.")) Then Return s ElseIf (s.StartsWith("http://")) Then If (s.Contains("www.")) Then s = "http://www." & s.Substring(1, s.Count - 1) TextBox1.Text = s Return s Else s = "http://www." & s.Substring(7, s.Count - 7) TextBox1.Text = s Return s End If ElseIf (s.StartsWith("https://")) Then If (s.Contains("www.")) Then s = "https://" & s.Substring(12, s.Count() - 12) TextBox1.Text = s Return s Else s = "https://www." & s.Substring(8, s.Count - 8) TextBox1.Text = s Return s End If Else If (s.StartsWith("www.")) Then s = "http://www." & s.Substring(4, s.Count() - 4) TextBox1.Text = s Return s Else s = "http://www." & s TextBox1.Text = s Return s End If End If End Function
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim url As String = checkURL() Try Dim fo As New SaveFileDialog fo.Filter = "Executable File|.exe|All Files|*" fo.FilterIndex = 1 fo.RestoreDirectory = True fo.ShowDialog() Dim path As String = fo.FileName My.Computer.Network.DownloadFile(url, path) MsgBox("Finished!") Catch ex As Exception MsgBox("Failed") End Try End Sub Private Function checkURL() Dim s As String = TextBox1.Text.ToLower() If (s.StartsWith("http://www.") Or s.StartsWith("https://www.")) Then Return s ElseIf (s.StartsWith("http://")) Then If (s.Contains("www.")) Then s = "http://www." & s.Substring(1, s.Count - 1) TextBox1.Text = s Return s Else s = "http://www." & s.Substring(7, s.Count - 7) TextBox1.Text = s Return s End If ElseIf (s.StartsWith("https://")) Then If (s.Contains("www.")) Then s = "https://" & s.Substring(12, s.Count() - 12) TextBox1.Text = s Return s Else s = "https://www." & s.Substring(8, s.Count - 8) TextBox1.Text = s Return s End If Else If (s.StartsWith("www.")) Then s = "http://www." & s.Substring(4, s.Count() - 4) TextBox1.Text = s Return s Else s = "http://www." & s TextBox1.Text = s Return s End If End If End Function End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.