devxlogo

Invoke Async Call by XMLHTTPRequest in VB

Question:
I am using the XMLHTTPRequest object in Visual Basic to invoke an async call. How do I register a complete event handler of the XMLHTTPRequest object?

Answer:
You’re not going to be happy with this answer, but there isn’t any way to register an event handler in VB. The XMLHTTPRequest object doesn’t source the event in Visual Basic?only in a scripting environment. All that the async attribute of the Open command does is turn off blocking when the Send method is invoked. I was a little surprised myself when I discovered this, as it is definitely a bad implementation. Probably the simplest solution in this situation is to poll the XMLHTTP object until its readyState gets set to 4 (i.e., “complete”). This isn’t ideal, but unless you have a browser running within your application and can use the scripting version of the command, you’re basically out of luck.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.