Hoppa till innehåll

Sida 1 av 1
  • Du kan inte starta en ny tråd
  • Du kan inte svara i tråden

Replace funkar inte

#1
Medlem är utloggad   Wepe 

  • Flitig
  • PipPipPipPip
  • Grupp: Medlemmar
  • Inlägg: 562
  • Gick med: 2000-10-11

Skrivet 27 jun 2012, 09:31

Aaargh, jag blir galen. Har förökt ett tag nu att flytta över min sida från en gammal server hos Citynetwok till en ny men det dyker upp nya fel hela tiden. Just nu brottas jag med att en helt enkel replacefunktion som vägrar funka. Får meddelandet Invalid use of Null: 'replace' trots att det finns data i databasen och på den gamla servern (kopplad till samma databas) funkar det fint. Så här ser funktionen ut:

Function FixHTML(InputTxt)
	If NOT isnull(InputTxt) Then
		InputTxt = Replace(InputTxt,vbCrlf,"<br>")	
		InputTxt = Replace(InputTxt,"[rubrik]","<h1>")
		InputTxt = Replace(InputTxt,"[/rubrik]","</h1>")
		InputTxt = Replace(InputTxt,"[underrubrik]","<h2>")
		InputTxt = Replace(InputTxt,"[/underrubrik]","</h2>")
		InputTxt = Replace(InputTxt,"[b]","<strong>")
		InputTxt = Replace(InputTxt,"[/b]","</strong")
		InputTxt = Replace(InputTxt,"[fet]","<strong>")
		InputTxt = Replace(InputTxt,"[/fet]","</strong>")
		InputTxt = Replace(InputTxt,"[i]","<i>")
		InputTxt = Replace(InputTxt,"[/i]","</i>")
		InputTxt = Replace(InputTxt,"[u]","<u>")
		InputTxt = Replace(InputTxt,"[/u]","</u>")
		InputTxt = Replace(InputTxt,"[red]","<font color=""red"">")
		InputTxt = Replace(InputTxt,"[/red]","</font>")
		InputTxt = Replace(InputTxt,"[blue]","<font color=""blue"">")
		InputTxt = Replace(InputTxt,"[/blue]","</font>")
		InputTxt = Replace(InputTxt,"[color]","<font color=""blue"">")
		InputTxt = Replace(InputTxt,"[/color]","</font>")
		FixHTML = InputTxt
	End if	
End Function

Jag ser inget fel i koden och den funkar som sagt var på gamla servern.
Har tidigare frågat om nåt liknande i denna tråd men då var det tillsammans med regExp och det (tror) jag är löst genom att jag bytte regExp-script.
Är det någon där ute som upplevt samma sak och vet bot?
// Wepe
0

#2
Medlem är utloggad   Cluster 

  • Omniscient
  • Ikon
  • Grupp: Moderatorer
  • Inlägg: 7 833
  • Gick med: 2000-08-08

Skrivet 27 jun 2012, 11:09

Flytta ut tilldelningen ur if-satsen samt fixa till input, typ:
Function FixHTML(str)
   str = cStr(Trim(str & " "))
   If str<>"" Then
      str = Replace(str, vbCrlf,"<br>")      
      str = Replace(str, "[rubrik]", "<h1>")
      str = Replace(str, "[/rubrik]", "</h1>")
      str = Replace(str, "[underrubrik]", "<h2>")
      str = Replace(str, "[/underrubrik]", "</h2>")
      str = Replace(str, "[b]", "<strong>")
      str = Replace(str, "[/b]", "</strong")
      str = Replace(str, "[fet]", "<strong>")
      str = Replace(str, "[/fet]", "</strong>")
      str = Replace(str, "[i]", "<i>")
      str = Replace(str, "[/i]", "</i>")
      str = Replace(str, "[u]", "<u>")
      str = Replace(str, "[/u]", "</u>")
      str = Replace(str, "[red]", "<font color=""red"">")
      str = Replace(str, "[/red]", "</font>")
      str = Replace(str, "[blue]", "<font color=""blue"">")
      str = Replace(str, "[/blue]", "</font>")
      str = Replace(str, "[color]", "<font color=""blue"">")
      str = Replace(str, "[/color]", "</font>")
   End If
   FixHTML = str
End Function


2

#3
Medlem är utloggad   Wepe 

  • Flitig
  • PipPipPipPip
  • Grupp: Medlemmar
  • Inlägg: 562
  • Gick med: 2000-10-11

Skrivet 27 jun 2012, 12:19

Visa inläggCluster, den 27 jun 2012, 11:09, sa:

Flytta ut tilldelningen ur if-satsen samt fixa till input, typ:

Sweet, nu funkar det. Kudos till dig :thumbsup:
// Wepe
0
Sida 1 av 1
  • Du kan inte starta en ny tråd
  • Du kan inte svara i tråden

1 besökare läser just nu den här tråden, varav 0 medlem(mar) och 1 gäst(er)
 
 
Senast obesvarade trådar
Prenumerera på nyheter

Missa inte våra nya
smarta nyhetsbrev

Läs mer om nyhetsbreven här!
Beställ direkt:


Extreme
PC för Alla-nätverket