Question

I'm trying to use HTTP in VB6 project

Dim httpCnct As XMLHTTP40
Set httpCnct = CreateObject("Msxml2.XMLHTTP.4.0")

but when i run the code, the compiler highlight the above line and show me an error: type not defined

Do I need to add some reference and, how to use it ?

Was it helpful?

Solution

C:\Users>reg query hkcr /f xmlhttp

HKEY_CLASSES_ROOT\Microsoft.XMLHTTP
HKEY_CLASSES_ROOT\Microsoft.XMLHTTP.1.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.3.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.4.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.5.0
HKEY_CLASSES_ROOT\Msxml2.ServerXMLHTTP.6.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.3.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.4.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.5.0
HKEY_CLASSES_ROOT\Msxml2.XMLHTTP.6.0

End of search: 12 match(es) found.

Also be aware there is a limit on how many times you can call any particular XMLHTTP object before a lockout occurs. If that happens, and it does when debugging code, just change to a different xmlhttp object

It is probably wiser to change

Set httpCnct = CreateObject("Msxml2.XMLHTTP.4.0")

to (if I remember my vb6 syntax)

Set httpCnct = New Msxml2.XMLHTTP.4.0

This would give you fast early binding rather than slow late binding. Changing the Dim to object will slow things down.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top