Hi, What am i doing wrong here? Any idea? Microsoft VBScript runtime error '800a000d' Type mismatch /publications/orderforms/processorders.asp, line 58 ---------------------------------- Function Clean(byVal value) If value <> "" Then value = Replace(value,"""","""""") value = Chr(34) & value & Chr(34) End If Clean = value End Function ----------------------------------------- sHeaderRow = "" sValueRow = "" ' FIRST LOG ALL THE FORM VARIABLES FOR EACH sItem In Request.Form ' DON'T LOG THE FULL CREDIT CARD NUMBER (LAST 4 LOGGED BELOW) IF sItem <> "card_accountNumber" THEN tempItem = sItem tempValue = Request.Form(sItem) IF sHeaderRow = "" THEN sHeaderRow = Clean(tempItem) ELSE sHeaderRow = sHeaderRow & "," & Clean(tempItem) END IF -------------------------------------------------- why do I get type mismatch at If value <> "" Then line in Clean function? the byVal value parameter is always a string because the tempItem is going to be a string. I even tried to do this tempItem = cStr(sItem) or CStr(value) <> "" to no avail. Any help in solving his legacy code is appreciated. The new It guy
Ah! That brings back memories. Sometimes the only way around it if forcing a conversion to a string doesn't work is to check for length or NULL, or 0 i.e. if len(value)<1 or If value IsNULL (can't remember the exact syntax for NULL).
Hi RonBrown, I changed things as you suggested but nothing changed. Function Clean(byVal value) If len(value) > 1 & IsNull(value) = false Then value = Replace(value,"""","""""") value = Chr(34) & value & Chr(34) End If Clean = value End Function
Bummer. What I'd be doing now is writing the values to the page both before and after the function. Do this just so you can see what is going on. Even do some checks like "isString" to see what type of variable is being passed Change the function so it does the conversion irrespective of the value. Something like.. Function Clean(content) content = Replace(content,"""",""""") content = Chr(34) & content & Chr(34) Clean = content end function On error resume next ' don't want it stopping for errors With Response .write value If isString(value) then .write "Value is a string" else .write "Value is something else" End if .flush Clean(value) .write value .flush end With All you're trying to do is establish exactly what is going on. What values are being passed and how they are being affected by the function. Once you figure out what the values are that are being passed (strings, integers, NULL) then you can figure out what your function is doing/not doing.
I may be wrong here but shouldn't you be sending the value to the Clean function rather then the object itself? e.g: sHeaderRow = Clean(tempValue) I haven't used vbscript for a while but if you performing string functions on an object then you will probably get a Type Mismatch error.