Results 1 to 6 of 6

Thread: HyperLink Insertion on FORMS

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Bangalore
    Posts
    2

    Post

    Hi Everyone!

    Can anyone tell me how i can place a HYPERLINK on a FORM and activate the link when clicked using the mouse. Suggestions and comments with examples will greatly be appreciated.

    Thanks in advance.
    Dilson
    [email protected]

  2. #2
    Member
    Join Date
    Jan 2000
    Posts
    35

    Post

    create a module with this 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
    '
    '
    Public Sub OpenFile(Path As String)
    Call ShellExecute(App.hInstance, "Open", _
    Path, "", Path, 1)
    End Sub

    create a form with this code and a command button:

    Option Explicit

    Private Sub Command1_Click()
    OpenFile "http://www.vbworld.com"
    End Sub

    instead of a command button you could use a label & mouse move to get color change and underline effects

  3. #3
    Member
    Join Date
    Jan 2000
    Posts
    35

    Post

    If you want a more refined touch try using drag and drop instead of mouse move like this (just remember to set the labels DragIcon (properties window) to the desired cursor):



    Private Sub Label1_DragDrop(Source As Control, x As Single, Y As Single)
    If Source = Label1 Then
    OpenFile "http://www.vbworld.com"
    End If
    End Sub
    '
    Private Sub Label1_DragOver(Source As Control, x As Single, Y As Single, State As Integer)
    If State = vbLeave Then
    With Label1
    .Drag vbEndDrag
    .ForeColor = vbBlack
    End With
    End If
    End Sub
    '
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    With Label1
    .Drag vbBeginDrag
    .ForeColor = vbBlue
    .Font.Underline = True
    End With
    End Sub


    This give a kind of mouse leave event

  4. #4
    New Member
    Join Date
    Feb 2000
    Location
    Geelong, Vic, Aus
    Posts
    8

    Post

    First, Create a label and call it "lblUrl"
    Next, Have a module that contains the following code:
    ---------------------
    Public Const URL = "http://www.Whatever.com"
    Private Const SW_SHOWNORMAL = 1

    Public Sub HyperLink()
    Dim lSuccess As Long
    lSuccess = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", SW_SHOWNORMAL)
    If lSuccess <= 32 Then
    MsgBox "Error", vbCritical
    End If
    End Sub
    ---------------------

    Third Add this code to the form
    ---------------------
    Private Sub lblURL_Click()
    HyperLink
    End Sub


    Private Sub Form_Load()
    lblurl.ForeColor = &HFF0000
    End Sub

    -------------------

    The following code may also be added to give a "Visited" look:
    -------------------
    Private Sub lblurl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    lblurl.ForeColor = &HFF&
    End Sub
    -------------------

    Bye


  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    If you want something a little cleaner and easier to use, then you could checkout my Freeware YoungURL OCX

    It includes a few extra features like:

    Customizable..
    Link Color/Hover Color
    Hover Style, (Bold, Underline, Strikethrough & None)
    Specify wether to use a New instance of a Browser/Email Client or an Existing one.
    etc..

    If you use it, let me know what you think.

  6. #6
    Member
    Join Date
    Jan 1999
    Location
    Gig Harbor, WA, USA
    Posts
    48

    Post

    I also wrote my own HyperLink OCX available at my website:

    http://www.cromas.net/

    Go to Visual Basic:Controls

    Good Luck!
    (¯`·.¸¸.·´¯`·-&gt;ShadowCrawler&lt;-·´¯`·.¸¸.·´¯)
    Teenage Programmer
    Visual Basic, HTML, C++, JavaScript

    http://welcome.to/X12Tech
    Email: [email protected]
    ICQ#: 9872708

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width