Cannot print the content from a given string using Mid() function

Discussion in 'C#' started by wonder_gal, Oct 12, 2005.

  1. #1
    I am supposed to return the content value within the tags "<RESULT>SUCCESS</RESULT>". So I had code it as

    <%
    tmpStartPos = InStr(StrObject, "<RESULT>") + 8 '8 is the length of string "<RESULT>"
    tmpEndPos = InStr(StrObject, "</RESULT>")
    Set sContent = Mid(StrObject, tmpStartPos + 1, tmpEndPos - tmpStartPos)

    %>

    but when i try to print out the sContent value, i got nothing.

    Can anyone pls point out to me what's the problem?
    Thanks alot.
     
    wonder_gal, Oct 12, 2005 IP
  2. Skeleton

    Skeleton Peon

    Messages:
    116
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why don't you remove that Set keyword before sContent variable. So that line must be like this:

    sContent = Mid(StrObject, tmpStartPos + 1, tmpEndPos - tmpStartPos)

    The keyword Set is used for setting objects, but in this case you are just setting a string variable. No need to use Set there.
     
    Skeleton, Oct 12, 2005 IP
  3. wonder_gal

    wonder_gal Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yaya, it works. Thanks. Your advice is very much appreciated. Have a nice day.
     
    wonder_gal, Oct 12, 2005 IP
  4. sufyaaan

    sufyaaan Banned

    Messages:
    218
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Basically Set is used when you are going to initialize an Object variable.
     
    sufyaaan, Oct 12, 2005 IP