Type mismatch Error: VBScript runtime error '800a000d'

Discussion in 'C#' started by dinpsaur, Mar 3, 2010.

  1. #1
    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 :confused:
     
    dinpsaur, Mar 3, 2010 IP
  2. RonBrown

    RonBrown Well-Known Member

    Messages:
    934
    Likes Received:
    55
    Best Answers:
    4
    Trophy Points:
    105
    #2
    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).
     
    RonBrown, Mar 4, 2010 IP
  3. dinpsaur

    dinpsaur Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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
     
    dinpsaur, Mar 11, 2010 IP
  4. RonBrown

    RonBrown Well-Known Member

    Messages:
    934
    Likes Received:
    55
    Best Answers:
    4
    Trophy Points:
    105
    #4
    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.
     
    Last edited: Mar 11, 2010
    RonBrown, Mar 11, 2010 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    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.
     
    camjohnson95, Mar 15, 2010 IP
  6. calvin199

    calvin199 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    having similar problems
     
    calvin199, Apr 13, 2010 IP