Can anyone tell me how to turn a text web address on a form into a hyper link
Thanks
Printable View
Can anyone tell me how to turn a text web address on a form into a hyper link
Thanks
Code:'add this to the form
Private Sub Command1_Click()
Call ShellExecute(0&, vbNullString, "www.aol.com", vbNullString, vbNullString, vbNormalFocus)
End Sub
[Edited by dimava on 08-29-2000 at 07:31 PM]Code:'put this in a module
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
'you can post and ask how to change the cursor to a handCode:
assuming your text is the caption of label1
'bas module code
Option Explicit
'
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 Function ShellToBrowser%(Frm As Form, _
ByVal URL$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(Frm.hwnd, "open", URL$, "", _
App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
Dim msg As String
msg = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
Dim msg1 As String
msg1 = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
Else
'It worked!
ShellToBrowser% = True
End If
End Function
'
'form code
Option Explicit
Private Sub Label1_Click()
Dim Site As String
Dim success As Integer
Site = Label1.Caption
success% = ShellToBrowser(Me, Site, 0)
End Sub
'kedaman posted it as an answer so he may be able to point you to it