eHarmony Promotional Code - Home Loans - Loans - Mobile Phones - Charity

PDA

View Full Version : Cannot print the content from a given string using Mid() function


wonder_gal
Oct 12th 2005, 3:00 am
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.

Skeleton
Oct 12th 2005, 3:23 am
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.

wonder_gal
Oct 12th 2005, 6:49 pm
Yaya, it works. Thanks. Your advice is very much appreciated. Have a nice day.

sufyaaan
Oct 12th 2005, 10:52 pm
Basically Set is used when you are going to initialize an Object variable.