Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Very Simple

Posted on 1999-07-06
Medium Priority
Last Modified: 2010-05-02
I forgot the code I had for making a label a weblink.
It started like this, please help me finish it.
Private Sub Label1_Click()
Dim label1 as Hyperlink

I forgot the rest.
Question by:newbie001
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
LVL 10

Expert Comment

ID: 1522399
try this...

Label1's OnClick()

call ShellExecute(0, "open", label1.caption, vbNullString, vbNullString, SW_SHOWNORMAL)

ShellExecute() is a Win API so you gotta declare it...

Label1.NavigateTo Label1.Caption might work also... i dunno.. :))


Expert Comment

ID: 1522400
newbie are you using VB6?


Author Comment

ID: 1522401
Yes I am using vb6, I thought I had it working without declaring anything, So (for now) I am gonna viktornets answer.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 1522402
I haven't used the hyperlink object in a VB project, but I don't think you are recalling the code correctly.

So, I'm not sure what the right answer is. The quick and easy answer is to create the label, set the caption, draw a line under it manually, and use Viktor's code in the OnClick event. But, you will have to declare the ShellExecute API call.

You could just use the built in shell statement and avoid the API declaration.

If you want to hide the URL behind a more friendly web page name, you can use the .tag to hold the URL and the .caption to hold the friendly name like so:

Form_Load() 'or where ever is more appropriate
 label1.tag = ""
 label1.caption = "Goto Experts-Exchange"
End Sub

 shell label1.tag, vbNormalFocus
End Sub

Of course, you won't get the visual indication of the mouse turning into a pointing hand unless you add code to the Form_MouseMove() and Label1_MouseMove() events to manipulate the cursor.

I took a look around the KB at MS and I couldn't find an example of what you are trying to do. Were you perhaps using an Active Document?


Author Comment

ID: 1522403
Well looks like the declare may be the best way, If viktornet re-answers I will accept the answer so he gets the points

Expert Comment

ID: 1522404
Sounds good.

Accepted Solution

pakos earned 20 total points
ID: 1522405
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

Call HyperJump("")

u can change ur mouse pinter to the finger one
and on mouse over change the color
and it works

LVL 10

Expert Comment

ID: 1522406
newbie, if you want me to get the points, you have to reject pakos' answer and let me answer... 10x


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question