webForumDet fria alternativet

Replace på en null sträng

4 svar · 236 visningar · startad av Pace

PaceMedlem sedan juni 20019 024 inlägg
#1

Varför i he***te ger detta felmeddelande:

"Ogiltig användning av Null: 'Replace'"

Function htmlSecure(htmlfix)
   If (htmlfix = Null) OR (htmlfix = "") OR (Len(htmlfix) <= 0) Then Exit Function

   htmlfix = Replace(Trim(htmlfix), "<", "<")
   htmlfix = Replace(htmlfix, ">", ">")
   htmlfix = Replace(htmlfix, vbCrLf, "<br>")
   htmlSecure = htmlfix
End Function

Jag begriper mig inte på Microsoft...

------------------
Peter D

VideMedlem sedan dec. 19998 577 inlägg
#2

Du borde nog göra såhär med null:

IsNull(htmlfix)

If IsNull(htmlfix) OR (htmlfix = "") OR (Len(htmlfix) <= 0) Then Exit Function

------------------
Vide rox = new Vide();
rox.learn("C#");

webeye.nu

PaceMedlem sedan juni 20019 024 inlägg
#3

Tack Vide!

Men varför funkar inte det andra?

------------------
Peter D

LarsGMedlem sedan dec. 200012 464 inlägg
#4

if [b]isNull(htmlfix)[/b] OR (htmlfix = "") OR (Len(htmlfix) <= 0) Then Exit Function

Alla jämförelser av typ


  värde op null

blir alltid falska.

------------------
essentitia preter non sans multiplicandum

PaceMedlem sedan juni 20019 024 inlägg
#5

Okej, jag förstår! Tack.

------------------
Peter D

127 ms totalt · 3 externa anrop · v20260731065814-full.fb544a5a
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)