• Log in or sign up for an account here: https://www.sythe.org/login

Need some help with this code

Cody

Grand Master

Visual Basic Programmers
Joined
May 10, 2005
Sythe Gold
30
Messages
3,052
Age
36
Location
USA, Oregon
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?
 
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()
 
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
 
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
 
Humm so it's working for you? Some reason when I use the function nothing happens.

Im testing it with

<a>test</a>
 
<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.
 
split may be annoying at times but it is commonly the most effective way to do stuff like this
 
Runescape Gamblingrunescape gambling
Back
Top