Results 1 to 4 of 4

Thread: How to display the anchor text of a link in a label ???!!!!!!! a

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Exclamation How to display the anchor text of a link in a label ???!!!!!!! a

    I need to display in a label the anchor text of a link, this link is in a website for example:

    <a href="url">Link text</a>

    I need display in the label the "Link Text" . I only know the url for example :
    http://www.adoretube.com , so if the link is :


    <a href="http://www.adoretube.com">videos cristianos</a> I need display in the label "videos cristianos" or if the link is :
    <a href="http://www.adoretube.com">musica</a> I want to display "musica"

    Can you help me?

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How to display the anchor text of a link in a label ???!!!!!!! a

    Set the LinkLabel Text property to any text you want and in the event LinkClicked use the target url address you want to visit.

    vb Code:
    1. Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
    2.         LinkLabel1.LinkVisited = True
    3.         System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe", "www.msdn.com")
    4.     End Sub



  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    294

    Re: How to display the anchor text of a link in a label ???!!!!!!! a

    Thanks but I need other thing. I need to extract the anchor text (innertext) and display it in a label.


    Quote Originally Posted by 4x2y View Post
    Set the LinkLabel Text property to any text you want and in the event LinkClicked use the target url address you want to visit.

    vb Code:
    1. Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
    2.         LinkLabel1.LinkVisited = True
    3.         System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe", "www.msdn.com")
    4.     End Sub

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How to display the anchor text of a link in a label ???!!!!!!! a

    Ah... Sorry, misunderstood
    Try this function

    vb Code:
    1. Private Function GetAnchor(ByVal strUrl As String) As String
    2.         Dim intL As Integer
    3.         Dim intG As Integer
    4.  
    5.         intG = strUrl.IndexOf(">") + 1
    6.         intL = strUrl.IndexOf("<", intG)
    7.         Return strUrl.Substring(intG, intL - intG)
    8.  
    9.     End Function



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