Friday, January 2, 2015

Visual Basic 6 : Open URL module

Ever heard VB6? Yeah, sound classic and bring back the memories. Today, I’m googling something then stumble with these module about open an URL from component such label or button with default web-browser.

Just add new module from your project and paste this visual basic code

Public 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
Public Sub OpenURL(website As String, sourceHWND As Long)
Call ShellExecute(sourceHWND, vbNullString, website, vbNullString,vbNullString, 1)
End Sub

From component (such as Label), you can trigger user to open an URL with this:

OpenURL "http://www.kriptonium.com", Me.hwnd

Nice huh? Well that all for now. See you later :)

No comments:

Post a Comment