Need some help with this code

Discussion in 'Archives' started by Cody, May 30, 2007.

Need some help with this code
  1. Unread #1 - May 30, 2007 at 11:43 PM
  2. Cody
    Joined:
    May 10, 2005
    Posts:
    3,052
    Referrals:
    5
    Sythe Gold:
    30

    Cody Grand Master
    Visual Basic Programmers

    Need some help with this code

    Im having trouble trying to figure out how to do what I need.

    What I need to do is edit out a link of code inside this text box and then place the new code in a new text box

    Im trying to remove all links from html code.

    So I need my program to see <a> and </a> and delete everything in-between it including the <a>,</a>

    Anyone know how to do this? use wild or something?
     
  3. Unread #2 - May 31, 2007 at 12:42 AM
  4. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Need some help with this code

    Using split so it will be pretty unstable and i've done this in the quick reply so it may throw errors :(

    Code:
    private functionDeleteTags(HTML as string) as string
        dim temp() as string, thold as string, thold2() as string, i as long
        do until instr(1,html,"<a>") = 0
            temp() = split(html,"<a>")
            thold = temp(0)
            thold2() = split(temp(1),"</a>")
            for i = 1 to ubound(thold(2))
                thold = thold & "</a>" thold2(i)
            next i
            for i = 2 to ubound(temp())
                thold = thold & "</a>" temp(i)
            next i
        loop
    end function
    Don't know how that will work, but if you need one really bad i can make an error free one using instr()
     
  5. Unread #3 - May 31, 2007 at 12:48 AM
  6. Cody
    Joined:
    May 10, 2005
    Posts:
    3,052
    Referrals:
    5
    Sythe Gold:
    30

    Cody Grand Master
    Visual Basic Programmers

    Need some help with this code

    I think I can figure it out thanks Covey :)

    If you have the time.... You could make one using Instr XD

    Ill of course give you credit
     
  7. Unread #4 - May 31, 2007 at 12:51 AM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Need some help with this code

    yer i just tested that and it failed big time lol

    EDIT:
    fixed the code, works now and tested.
    Code:
    Private Function DeleteTags(HTML As String) As String
        Dim temp() As String, thold As String, thold2() As String, i As Long
        Do Until InStr(1, HTML, "<a>") = 0
            temp() = Split(HTML, "<a>")
            thold = thold & temp(0)
            thold2() = Split(temp(1), "</a>")
            For i = 1 To UBound(thold2())
                If i = 1 Then
                    thold = thold & thold2(i)
                Else
                    thold = thold & "</a>" & thold2(i)
                End If
            Next i
            For i = 2 To UBound(temp())
                thold = thold & "</a>" & temp(i)
            Next i
            HTML = thold
        Loop
        DeleteTags = HTML
    End Function
     
  9. Unread #5 - May 31, 2007 at 9:18 AM
  10. Cody
    Joined:
    May 10, 2005
    Posts:
    3,052
    Referrals:
    5
    Sythe Gold:
    30

    Cody Grand Master
    Visual Basic Programmers

    Need some help with this code

    Humm so it's working for you? Some reason when I use the function nothing happens.

    Im testing it with

    <a>test</a>
     
  11. Unread #6 - May 31, 2007 at 11:21 AM
  12. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Need some help with this code

    <a>test</a> will return nothing as it removes the <a></a> tags and the shits inside them.

    if you did "hi<a>blah</a> lol" it would return "hi lol".

    but it stuffs up with there is alot of tags. so its not very usefull. If you really desperately need a function that will actually work i could make it, but it would take awhile.
     
  13. Unread #7 - Jun 4, 2007 at 3:22 PM
  14. -------owned-------
    Joined:
    Jan 27, 2007
    Posts:
    1,225
    Referrals:
    0
    Sythe Gold:
    0

    -------owned------- Guru
    Banned

    Need some help with this code

    Split is teh shit ;)
     
  15. Unread #8 - Jun 4, 2007 at 3:29 PM
  16. Puzzle
    Joined:
    May 6, 2005
    Posts:
    846
    Referrals:
    0
    Sythe Gold:
    0

    Puzzle Apprentice

    Need some help with this code

    split may be annoying at times but it is commonly the most effective way to do stuff like this
     
< Coins Changed Slightly? | fally riot?! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site