This is the Personal Stock Monitor scripting developers forum.
Not logged in.
2011-01-21 05:00:37
1 of 6
#2845
The second MsgBox in the following code displays "TypeName = Empty", even though the first MsgBox displays the HTMLText text.

Len(HTMLText) displays blank.

How do I access the text in HTMLText?

Thank you.

Dim HTMLText
Dim xmlhttp   ' As MSXML2.XMLHTTP.3.0

Set xmlhttp = CreateObject("MSXML2.XMLHTTP.3.0")
xmlhttp.open "GET", myURL, False
xmlhttp.Send

If (xmlhttp.readyState = 4) Then
  If (xmlhttp.status = 200) Then
    HTMLText = xmlhttp.responseText
    MsgBox "xmlhttp was successful.  HTMLText = " & HTMLText, vbOKOnly, "note"
    MsgBox "TypeName = " & TypeName(HTMLText), vbOKOnly, "note"
Posted by: dgoyette
2011-01-21 09:56:56
2 of 6
#2846
in reply to #2845
responseText is a property, not an object, so you can't get it's type or length. Assign it to a string variable first, then you will be able to manipulate it as a string.
Posted by: Anatoly
2011-01-21 16:38:49
3 of 6
#2847
in reply to #2846
Howdy Anatoly,

Isn't that what "HTMLText = xmlhttp.responseText" does?

The first MsgBox statement DOES display the HTML from the requested web page.

Today, the second MsgBox statement DOES display "TypeName = String".

However, none of the string functions I try to use on HTMLText work. For example:

Len(HTMLText) displays "" (nothing)

InStr(HTMLText,"<some search string>") displays "" (nothing)

etc.

What am I missing?

Thank you.
Posted by: dgoyette
2011-01-21 16:44:56
4 of 6
#2848
in reply to #2846
In other words, the HTMLText string can be displayed, but NOT manipulated directly?
Posted by: dgoyette
2011-01-21 17:55:47
5 of 6
#2849
in reply to #2848
Not sure what to tell you. I haven't used responseText since I would normally go through the DOM to find what I want, but it must be something simple. I would suggest doing some google searches.
Posted by: Anatoly
2011-01-22 16:36:13
6 of 6
#2850
in reply to #2849
It was a misplaced comma in my code. Sorry.
Posted by: dgoyette