Fog Creek Software
Discussion Board

Best way to access internet using VB?

I am working on the requirements of an application and I am using a prototype written in VB to test some concepts.

Right now I need to access a few HTML pages and I have no expert on the subject in the vicinity.
So far, from browsing the Web and some other sources, I have arrived at the Inet control.
I tried to use "wininet.dll", but had some strange results of which I am not sure they were my not understanding it properly, or wininet having issue. I noticed similarly issues in some example code I found, so it got me suspicious enough not to invest more time in wininet.

However, although I do not need the latest and greatest just for this prototype -- an expert developer can pick up on the requirements and logical design where I left of, but I am curious if there are other techniques that I can use to make things even simpler for me.

Any ideas are welcome, although I must say that dot net would probably involve to many other obstacles to save me any time. Not to mention the fact that I only have VB 6 at my disposal right now.

Practical Geezer
Tuesday, July 15, 2003

For a prototype, I would just use the IE control. You will find this control listed as "Microsoft Internet Controls" when you reference it from VB.

Different internet protocols required different approaches. I have implemented telnet, ftp, and nntp using VB6. The first time you learn/implement these is a non-trivial effort. Once you get the basics of winsock, then it is a matter of looking up RFCs of these protocols and coding according to specs.

I've been using the SocketWrench (free edition) to do this. The company is Catalyst Software at  I only use the winsock control that comes with VB for prototyping. I use SocketWrench when I need something in production.

I'm part of an open sourced VB6 project to create a type of telnet server. There are several people that know internet programing using VB6 on the forums over there. The URL is

Tuesday, July 15, 2003

What do you mean by 'Access'?
Loading data from a URL? Easiest control to use is xmlhttp.

Tuesday, July 15, 2003

I should have been more precise. I am accessing a server using HTTP as a carrier. The URL contains a command for the server, which returns via HTTP a page with the results.
The page does not actually contain any HTML.

What I do now is use OpenUrl of the Inet control.
The Inet control takes care of the HTTP stuff and it returns the page that the server produces as a result.

So as far as simplicity is concerned, it can't get much simpler I suppose. At least for now, when I can get away with synchronous communication.
I will probably need asynchronous communication for the next stage.

But still, is the Inet control still "fashionable", or is there a new and improved way of achieving this simple task?

Practical Geezer
Tuesday, July 15, 2003

You got the first stage working, so I wouldn't mess with it for now. You'll need to look at the RFC for the HTTP protocol if you need to do anything more complex.

IIRC, HTTP is an synchronous and stateless protocol. Anything outside of that, you'll have to hand code it

There's not much else we can say without details.

Tuesday, July 15, 2003

FYI, VB's browser control requires that you have I.E. installed.

I.E. comes standard on Windows 2000 and above PCs, so perhaps this isn't a big issue.

BTW, I personally hate to write commercial software that's dependent on a big lug of a component that has umpteen different versions and is just so complex that bugs are hard to keep up with.

FWIW, this sort of problem just happened to ME as a user with GoldMine. It uses the MSHTML.dll for HTML email and MS broke Goldmine's email (via a bug in a new version of MSHTML).

Tuesday, July 15, 2003

well, then stick with the inet control (which I don't know).
xmlhttp will handle async just fine if you want to go that way. urlmon and wininet are much more difficult to use (xmlhttp is in fact a wrapper).

unless you're trying to do something highly obscure, or maybe are doing some sort of batch download, xmlhttp is pretty much guaranteed to handle everything you need with http.

btw, there are lots of protocols (XML-RPC, SOAP) which sound relevant to your needs if you're designing something new. there are wrappers for them (e.g. MSSOAP) too.

Tuesday, July 15, 2003

Inet does seem fine sofar.
Right now the prototype uses OpenURL, which returns the result synchronously.
I have no need for multiple outstanding requests, but the real thing will need to be able to interrupt a request. In case the end-user changes his mind, or decides not to want to wait any longer.

Practical Geezer
Wednesday, July 16, 2003

Why don't you just use the MSXML libraries?

You can make HTTP requests to web servers and then retrieve the results without the over head of controls. It's just a bunch of classes. You can make Get or Post requests too - very easy, yet powerful.

You need to download the MSXML libraries for VB6 from Microsoft - it's free.

Here's a HTTP GET example returning a string:

Public Function getHTTPRequestSTRING(URL As String) As String


    Set HTTP = New MSXML2.XMLHTTP40 "GET", URL, "false"
    getHTTPRequestSTRING = HTTP.responseText

    Set HTTP = Nothing

End Function

You can also get a XML data type back from a web server by using the HTTP.responseXML instead of the HTTP.responseText method.

Hope this helps!!!!!!

Wednesday, July 16, 2003

I will certainly look into it. Thanks!

Practical Geezer
Wednesday, July 16, 2003

*  Recent Topics

*  Fog Creek Home