I would like opinions/suggestions for improvement etc on the following function. It will be wrapped around every value being passed into a CSV file on a classic ASP page. As is below it is handling all situations we are up against, for now....
I would like to know why If Len(txt) = 0 Then fails when it is run in the page that creates the CSV file althouh runs fine when in a regular ASP page. I ma having to use If "" & txt = "" Then to make it work on both pages
function insertCSV(txt)
  'If Len(txt) = 0 Then    
  If "" & txt = "" Then
      Exit Function
  Else
    Dim tmp
    tmp = txt
    if isNumeric(tmp) then
        if left(tmp, 1) = "0" then
            tmp = """" & tmp & """"
        else
            tmp = tmp
        end if
    else
        tmp = Replace(tmp, """", """""")
        if instr(tmp, ",") or instr(tmp, """") then tmp = """" & tmp & """" 
        if instr(tmp, "®") then tmp = replace(tmp, "®", "®")
        if instr(tmp, "™") then tmp = replace(tmp, "™", "™")
        if instr(tmp, "©") then tmp = replace(tmp, "©", "©")
        if instr(tmp, vbcrlf) then tmp = replace(tmp, vbcrlf, "")
        if instr(tmp, "Â") then tmp = replace(tmp, "Â", "")
    end if
    insertCSV = tmp
  End If
end function
 
     
     
    