VBScript/ASP Function not returning value

Posted on 2012-08-20
Last Modified: 2012-08-20
Hello Experts,

I've written a short function to replace characters in a string called from a database, but it doesn't seem to work... I usea similar function, written in the same way, and that does work, so I'm really confused!

Here's how I call the function:

adminnotes = unstriptext(RS("adminnotes"))

Open in new window

Admin notes currently holds the value 'test'

And here's the function, which is held in a seperate file which is inculded at the top of my page:

function unstriptext(note)
if len(note) > 0 then 
testnote = Replace(note, "''", "'")
testnote = Replace(testnote, CHR(13), "<BR>")
end if
end function

Open in new window

Thanks in advance for your help.
Question by:Nico2011
    LVL 35

    Accepted Solution

    You're not assigning anything to the function result "unstriptext", probably just replace "testnote" with that (3 times).
    LVL 35

    Expert Comment

    by:Robert Schutt
    NB: if len(note) = 0 then the function returns an empty value which may not be the intention. You could add an 'else' part for that.

    Author Closing Comment

    Thanks very much - how daft of me!  Works fine now...

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now