VBTut
Home
Tutorials
Resources
'Add 7 buttons a webbrowser and a timer. enable the timer and set the interval to 50. 'Right under public class form1 put: Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer 'and under that: Private Function Download(ByVal sFileRemote As String, ByVal sFileLocal As String, Optional ByRef errMessage As String = "") As Boolean Dim ret As Boolean = False Dim wc As New System.Net.WebClient() Try 'here is where download of file occurs wc.DownloadFile(sFileRemote, sFileLocal) ret = True Catch ex As Exception errMessage = ex.Message Return ret End Try Return ret End Function 'put this code on an invisible button: Dim sErr, myPath As String 'setup some vars sErr = "" : myPath = My.Application.Info.DirectoryPath Dim droppedLink As String = "http://www.born63.com/index.html" If Not myPath.EndsWith("\") Then 'hey what if installed in root? myPath &= "\" End If Dim sLocalFile As String = myPath & "index.html" If Not Download(droppedLink, sLocalFile, sErr) Then If sErr <> "" Then 'just tailoring error without really checking the error object for types of error. just a general error message MsgBox("Unable to accomplish file download due to following error:" & vbCrLf & sErr & vbCrLf & "Please examine this error and see if you can correct the problem. Then try to download " & droppedLink & " again.", MsgBoxStyle.Critical) Else MsgBox("Unable to accomplish file download due to unknown error:" & vbCrLf & sErr, MsgBoxStyle.Critical) End If End If End If 'Timer 1 Dim starthotkey As Boolean starthotkey = GetAsyncKeyState(Keys.f1) If starthotkey = True Then 'home button webbrowser1.gohome 'stop button webbrowser1.stop 'refresh button webbrowser1.refresh 'backward button webbrowser1.goback 'forward button webbrowser1.goforward 'go button WebBrowser1.Navigate(TextBox1.Text)