• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1116
  • Last Modified:

Problems with Inet Control in VB

I am fairly new to visual basic and this forum, so I apologize if this turns out to be a REALLY simple error.

I have been trying to make a web scraper and parse it into an Access Database. I wanted to use the Inet control however cannot seem to get it to work. (I get an Error 91 every time)  I have added the msinet.ocx file to the references and have googled every which way to write the code with no avail.

I was hoping someone here might have an Idea to help me out.
0
Brattlof54
Asked:
Brattlof54
  • 4
  • 4
  • 2
1 Solution
 
c0ldfyr3Commented:
You must not be too familiar with google o.O

Google "microsoft internet transfer control access" first result is http://support.microsoft.com/kb/163653

Option Compare Database
 
Dim objInet As Inet
 
Private Sub Form_Load()
    Set objInet = Inet0.Object
    
    Dim sHTML As String
 
    ' Set the internet transfer control protocol and URL.
    objInet.Protocol = icHTTP
    objInet.URL = "HTTP://www.microsoft.com"
    
    ' Retrieve the HTML data into a byte array.
    sHTML = objInet.OpenURL(objInet.URL, icString)
    
    MsgBox sHTML
 
End Sub

Open in new window

0
 
mdouganCommented:
Can you show any code that you've tried?  It is easier for us than starting from scratch.

Basically, you wouldn't add the OCX to the references, but rather, you would drag it off the tool bar and place it on your form.  I think the icon looks like a little globe.  If you don't see it on your toolbar, then right-click the toolbar and select Add Components from the popup menu, then browse to where your msinet.ocx control is, select it and it should appear on your toolbar.

Once you drag it to your form, it is like a little browser window.  Then, in your code, let's say the instance of the inet you put on your form was named iNet1, you would code something like:

iNet1.Nagivate "http://www.mywebsite.com"

Now, it takes a little while for the iNet1 control to get the contents of the web page, so, you might want to wait until you see the results on the form before trying to do your scraping.

When you're ready to parse the HTML, I believe the iNet1 control has a property called innerHTML or maybe Body... you might have to browse through the properties to find the likely one (it's pretty obvious).  That is a String that will contain all of the HTML retrieved from the web page.

That's about all there is to it!
0
 
Brattlof54Author Commented:
I think I narrowed down the problem. I tried mdougan's method and I think the problem seems to be with my license, and sadly I cannot justify the cost to upgrade.  Is there another way to get the source code?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mdouganCommented:
A problem with your VB6 license?

If there is an issue with your msinet.ocx, I believe that I have some sample code for making HTTP requests that do not use that OCX (though, I'll have to review what it does use).

If your problem is with the VB6 license, then, I don't know you mean by "is there another way to get the source code."
0
 
Brattlof54Author Commented:
Sorry about the delay on getting back to you.

But the problem is not with my VB6 (From what I understand I can use everything else except msinet)


0
 
mdouganCommented:
OK, well, please address the other posts?

It doesn't make much sense that you'd have trouble with msinet, unless you are behind some sort of firewall or proxy server.
0
 
c0ldfyr3Commented:
mdougan, the control you speak about in your post is not msinet, msinetis a transfer only conrol and has no graphical interface in run time.It displays as a picture of a little world in a 48x48 box at designtime. The control you describe, and which has a Navigate function, isthe Microsoft Internet Conrol....

Author, can you please decribe why you think the issue is with yourlicense? If you follow mdougans method for adding the control to theform, and use the code from my first post it should work.

The difference between Access and VB6 seems to be that you need to use the .object property of the control  from  Acces to access the actualy Inet object.
0
 
Brattlof54Author Commented:
When I try to add the Microsoft Internet Transfer Control 6.0 SP4 a pop-up message opens with the prompt You dont have the license required to use this ActiveX control. You tried to open a form containing an OLE object or an ActiveX control or you tried to create an ActiveX control. To obtain the appropriate license, contact the company that provides the licensed OLE object or ActiveX control.

 I assume that the license is with the the msinet.
0
 
mdouganCommented:
c0ldfyr3 is correct, I was mixing up the WebBrowser control with the msinet control.

I just tried c0ldfyr3's original code and it worked fine on my machine, but, I don't think I have sp4.

You could try selecting the Microsoft Internet Controls to place on the toolbar... mine is right above the Internet Transfer Control in the list.  Then, select the globe as mentioned above... that would create an instance something like

WebBrowser1

Your code would look like:

Dim sHTML as String

WebBrowser1.Navigate "http://www.mysite.com"

Do While WebBrowser1.Busy
   DoEvents
Loop

sHTML = WebBrowser1.Document.Body.innerText
MsgBox sHTML

If that doesn't work, I'll try to dig up my other HTTP code for you.
0
 
Brattlof54Author Commented:
Thank you for your help. I got everything working using the WebBrowser1.Document.Body method.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now