Hvorfor virker dette ikke
Blot for at teste denne funktion, som ikke virker odentligt, har jeg lavet en tekst-streng.Den returnerer kun én tal. Den skulle finde flere tal med komma imellem. Hvad er fejlen?
M.v.h.
Søren Peter
Function Loopnow(Tekst)
A_Start = 1
Str1 = vbCrlf ' Linjeskift
Str2 = " " ' Mellemrum
Str3 = "<" ' Start på Html- kode
Str4 = ". " ' Punktum + mellemrum
Str5 = "." & vbCrlf ' Punktum + linjeskift
Str6 = "," ' Komma ("Tumpesikret" - Normalt skriver man komma + mellemrum i sætninger)
do until A_Start >= len(Tekst)
LinkChr = InStr(A_Start, Tekst, "#")
If InStr(LinkChr,Tekst, Str1) > 0 Then sVals = InStr(LinkChr,Tekst, Str1)
If InStr(LinkChr,Tekst, Str2) > 0 Then sVals = sVals & " " & InStr(LinkChr,Tekst, Str2)
If InStr(LinkChr,Tekst, Str3) > 0 Then sVals = sVals & " " & InStr(LinkChr,Tekst, Str3)
If InStr(LinkChr,Tekst, Str4) > 0 Then sVals = sVals & " " & InStr(LinkChr,Tekst, Str4)
If InStr(LinkChr,Tekst, Str5) > 0 Then sVals = sVals & " " & InStr(LinkChr,Tekst, Str5)
If InStr(LinkChr,Tekst, Str6) > 0 Then sVals = sVals & " " & InStr(LinkChr,Tekst, Str6)
' Sørg derefter for at det er et gyldigt Array
sVals = Trim(sVals)
sVals = Replace(sVals," ",",")
' Find så den laveste tal for en position, som må være der hvor linket slutter
aVals = Split(sVals,",")
iLowest = aVals(0)
For iCnt = 0 to UBound(aVals)
If(aVals(iCnt) < iLowest) Then iLowest = aVals(iCnt)
Next
EndPos = iLowest
Response.Write EndPos
if Int(LinkChr) = Int(InStrRev(Tekst, "#")) then
Loopnow = EndPos & ","
A_Start = Len(Tekst)
else
A_Start = EndPos
end if
Loop
End Function
Loopnow("Virker det her eller# hvad?. eller #virker det, ikke#")
