Visual Studio Tutorials

      
       Search my site for your answer

    How do I create a simple hyperlink in VB.NET?

Creating a hyperlink in VB.NET is quite simple, the code you need is

System.Diagnostics.Process.Start("www.NJS Computing Services")

So the example above shows you how to create a hyperlink to my site www.NJS Computing Services

This time let's see an example with a label. So create a simple form like I have done below.

vb.net hyperlinks

Now add a label to it, so click on your Toolbox like I have done in the screen print below. Simply click on View and scroll down to "Toolbox" then left click on it.

visual studio creating hyperlinks is easy with my online tutorial

 

When you left click on it you will be shown the Toolbox index like mine below. Just scroll down until you come to one that says "Label" Then click on it, you may have to double click on it.

Toolbox in VS ultimate 2012

 

Then when you look at your design view you will see that a Label has been placed on your Form. Just look at mine below to see what I mean.. Now just double click on the label and it will take you to code view

labels in visual studio can be used to crete hyperlinks

 

When you have clicked on the label like I said above you will be shown the code view window. Look at my code view window below.

code view in vb.net

What we need to do is insert the hyperlink between the second line of text which is

"Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click"

and the third line of text which is
End Sub

So we have this

Public Class Form1

Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
System.Diagnostics.Process.Start("www.NJS Computing Services")
End Sub
End Class

My screen print look like


 

So what have we acheived? Well go back to design view then run your programme. If you are not sure how to do that just click on "Debug" "Start Debugging" Your form will open up. You can the click on your label or double click on it, you should see your default web browser open up. When it does www.NJS Computing Services will be there. :)

I hope you enjoyed my lesson, you can leave feedback to let others know by clicking this link