On Wed, 24 Sep 2003 12:00:14 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?
====================
I recently had to solve this problem. It is different for Windows
95,98,ME and Windows NT,2000,XP. Here is a cross-system solution.
Place a "Microsoft SysInfo control" on your form. Set the "label"
field that displays the web site URL to be underlined in the Font
attribute, set the MousePointer attribute to 99 (custom), and set the
MouseIcon to HAND-M.CUR (it is normally in the /windows/cursors
directory, I attached it). This will cause the web hand to show when
the cursor is placed over the label that has the web link.
' The declaration below goes in a Module1.bas file
' execute shell command
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
' This is the code to launch the browser (It assumes that
' the form with the SysInfo control is frmMain
Private Sub Label5_Click()
Dim rcu As Long
Dim URL As String
' ShellExecute defined in Module1.bas
URL = "http://www.yahoo.com/" ' or whatever
If frmMain.SysInfo1.OSPlatform = 2 Then
' OSPlatform = 2 for Win NT/2000/XP
Call ShellExecute(Me.hwnd, "open", URL, "", "", 0)
Else
' OSPlatform = 1 for Win 95/98/ME
rcu = Shell("start " & URL, vbNormalFocus)
End If
End Sub