- Version
- Download 118
- File Size 255.03 KB
- File Count 1
- Create Date March 2, 2016
- Last Updated March 2, 2016
Open a website in Visual Basic
Open a website in Visual Basic
A simple code in visual basic that will open a website on what the user enters in a textbox.
A step by step tutorial in a pdf format plus source code are included in the download file.
Source code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub cmdCancel_Click()
Unload Me
End Sub
Public Function OpenLocation(url As String, WindowState As Long) As Long
Dim lhWnd As Long
Dim lAns As Long
' Execute the url
lAns = ShellExecute(lhWnd, "open", url, vbNullString, vbNullString, WindowState)
OpenLocation = lAns
End Function
Private Sub Command1_Click()
Dim i As Long
Dim urls As String
Dim indexpath As String
indexpath = "http://" & text1.Text & ""
urls = Trim(indexpath)
i = OpenLocation(urls, 1)
End Sub