How Can I Create A link on A Form That When Clicked On Will Open A Web Browser And Take The User To My Web Site
My Web Site URL Is:
http://www.angelfire.com/fl3/crazymarc
Printable View
How Can I Create A link on A Form That When Clicked On Will Open A Web Browser And Take The User To My Web Site
My Web Site URL Is:
http://www.angelfire.com/fl3/crazymarc
Or just set the label to look like a blue color.Code:Public Enum OpType
Startup = 1
Click = 2
FormMove = 3
LinkMove = 4
End Enum
Dim Clicked As Boolean
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
Public Sub MakeLink(LabelName As Label, Operation As OpType, Optional FormName As Form)
Dim Openpage As Integer
Select Case Operation
Case LinkMove
LabelName.ForeColor = 255
LabelName.FontUnderline = True
Case Click
Openpage = ShellExecute(FormName.hwnd, "Open", LabelName.Caption, "", App.Path, 1)
LabelName.ForeColor = 8388736
Clicked = True
Case FormMove
LabelName.FontUnderline = False
If Not Clicked Then
LabelName.ForeColor = 16711680
Else
LabelName.ForeColor = 8388736
End If
Case Startup
LabelName.ForeColor = 16711680
End Select
End Sub
[Edited by Matthew Gates on 07-01-2000 at 04:18 AM]Code: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 Const SW_SHOWNORMAL = 1
Label_Click:
ShellExecute Me.hwnd, vbNullString, "http://www.site.com", vbNullString, "c:\", SW_SHOWNORMAL)
Module Code: Create a Bas Module and enter the following
Form Level Code: The Form needs two labels; lblEmail andCode:Option Explicit
Public Const URL = "http://angelfire.com/fl3/crazymarc"
Public Const email = "crazymarc@someplace"
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 Const SW_SHOWNORMAL = 1
Public Sub gotoweb()
Dim Success As Long
Success = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", SW_SHOWNORMAL)
End Sub
Public Sub sendemail()
Dim Success As Long
Success = ShellExecute(0&, vbNullString, "mailto:" & email, vbNullString, "C:\", SW_SHOWNORMAL)
End Sub
lblURL
Code:Private Sub Form_Load()
lblEmail = email
lblURL = URL
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
End Sub
Private Sub lblEmail_Click()
sendemail
End Sub
Private Sub lblURL_Click()
gotoweb
End Sub