Replace (Enter)& Addlinks blandet sammen i form
Jeg kan ikke få disse ting til at hænge sammen.Den første funktion addlinks fungerer og det andet kode replace fungerer - hver for sig.
Hvordan skal det sættes sammen eller hvad skal tilføjes, så at tekst hentet fra db kan vise link og ny linie samtidig.
:-) karsten_larsen
det første:
Function addLinks(sInput, sTarget)
Dim sNew, sPunct
' Define punctuation characters
sPunct = "_-+=!?.,;:`~'""*^$%()[]{}<>|"
' Assign input string to local variable so we don't change the
' original string.
sNew = sInput
' Split the string by whitespace: spaces, carriage returns, line feeds,
' and tabs. Then, for each "word" in the string...
For Each sVal1 in Split(sNew, " ")
For Each sVal2 in Split(sVal1, vbcr)
For Each sVal3 in Split(sVal2, vblf)
For Each sVal4 in Split(sVal3, Chr(9))
' Remove beginning and ending punctuation
bStop = FALSE
Do While (Not bStop)
If (Instr(sPunct, Left(sVal4, 1)) <> 0 And Len(sVal4) > 2) Then
sVal4 = Mid(sVal4, 2)
Else
bStop = TRUE
End If
Loop
bStop = FALSE
Do While (Not bStop)
If (Instr(sPunct, Right(sVal4, 1)) <> 0 And Len(sVal4) > 2) Then
sVal4 = Left(sVal4, Len(sVal4) - 1)
Else
bStop = TRUE
End If
Loop
' If the word begins with http:// then convert all occurrences
' of this word to a hyperlink.
If (LCase(Left(sVal4, 7) = "http://") Or LCase(Left(sVal4, 4) = "www.")) Then
If (LCase(Left(sVal4, 4) = "www.")) Then
If (sTarget = "") then
sNew = Replace(sNew, sVal4, "<A HREF='http://" & sVal4 & "'>" & sVal4 & "</A>")
Else
sNew = Replace(sNew, sVal4, "<A HREF='http://" & sVal4 & "' TARGET=""" & sTarget & """>" & sVal4 & "</A>")
End If
Else
If (sTarget = "") then
sNew = Replace(sNew, sVal4, "<A HREF='" & sVal4 & "'>" & sVal4 & "</A>")
Else
sNew = Replace(sNew, sVal4, "<A HREF='" & sVal4 & "' TARGET=""" & sTarget & """>" & sVal4 & "</A>")
End If
End If
End If
' If this word looks like an e-mail address then convert all
' occurrences into a mailto: link.
If (Instr(sVal4, "@") >= 2 And Instr(sVal4, ".") <> 0 And Len(sVal4) >= 5) Then
sNew = Replace(sNew, sVal4, "<A HREF=""mailto:" & sVal4 & """>" & sVal4 & "</A>")
End If
Next
Next
Next
Next
' Return converted string
addLinks = sNew
End Function
det andet:
tekstvariabel = objRecResultat("besked")
tekstvariabel = Replace(tekstvariabel, VbCrLf , "<BR>")%>
sat sammen i dette:
<%Response.Write(addLinks(tekstvariabel,"_blank"))%>
