[2008] Getting Started with VB.Net 2008 from VB6
Well I have been developing with VB6 for about 7 years now, and I think it is time I move on to VB.Net to future proof my skills... Not only that. I am learning C++, but that is beside the focus of this post.
Anyway, So I installed the VS 2008 Professional, I didn't install all the Windows Mobile SDK stuff, Just Visual Studio, MSDN, and the sql server...
So now I am ready to jump right in but I do have a few questions...
I do a lot of work with HTTP requests from within my applications, like building GET and POST requests and returning strings that are parsed and what not...
I was using the winHTTP COM object in vb6 for the longest time, and I loved it... It was structured nicely and when Dimmed "with events" opened up a nice way of implementing progressbars, calculating download speeds, etc etc...
So my first two questions are:
1) What is the .NET alternative of the winHTTP COM Object...
2) How do you dim objects withevents globally across a form class?
In vb6 I would dim my winHTTP object at the top of the form with events, and then I could implement all my progress bar code in the winhttp events that are exposed....
Also then in each subroutine you then have to set = new winhttp.winhttprequest to create the new object, blah blah blah...
Re: [2008] Getting Started with VB.Net 2008 from VB6
The place for you to start is probably with the WebClient class and the HttpWebRequest and HttpWebResponse classes. The WebClient is good for very simple Web coms but the request and response classes give you more control. Both options provide both synchronous and asynchronous methods.
A variable declaration in VB looks much as it did in VB6:If SomeType has events then you're able to handle those events of that variable, but you can only attach and event handler using the AddHandler statement. If you do this:
vb.net Code:
Private WithEvents var As SomeType
then you can include that variable in the Handles clause of a method to attach the event handler, which is generally simpler.