internet explorer

E

Etayki

Hi!

I am new to VB.net and I am using the Visual Basic 2005 Express
Edition

I have two questions:

1. I am trying to write an application that will automate Internet
Explorer and store data in a database. Am I better off learning VB.net
or C#.net? Is there a free development environment for C# as well?

2. I have followed examples in other posts and copied this code to
open up IE:

Imports SHDocVw
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim wbBrowser As New SHDocVw.InternetExplorer
wbBrowser.Visible = True
wbBrowser.Navigate("http://www.rediff.com", Nothing, Nothing,
Nothing, Nothing)
End Sub
End Class

These are my errors:

Warning 1 Namespace or type specified in the Imports 'SHDocVw' doesn't
contain any public member or cannot be found. Make sure the namespace
or the type is defined and contains at least one public member. Make
sure the imported element name doesn't use any aliases. C:\Documents
and Settings\Administrator\Local Settings\Application Data\Temporary
Projects\WindowsApplication3\Form1.vb 1 9 WindowsApplication3

Error 2 Type 'SHDocVw.InternetExplorer' is not defined. C:\Documents
and Settings\Administrator\Local Settings\Application Data\Temporary
Projects\WindowsApplication3\Form1.vb 5 30 WindowsApplication3

Can someone please help this newbe?
 
M

Martin H.

Hello Etayki,
1. I am trying to write an application that will automate Internet
Explorer and store data in a database. Am I better off learning VB.net
or C#.net?

That depends on you. If you are very familiar with C/C++, then you might
be more interested in C#. If you have ties to BASIC, then VB.NET might
be more interesting for you.
Is there a free development environment for C# as well?

Yes, there is. You can download it from the MS website at

<http://msdn.microsoft.com/vstudio/express/visualcsharp/default.aspx>

Best regards,

Martin
 
C

camainc

Hi!

I am new to VB.net and I am using the Visual Basic 2005 Express
Edition

I have two questions:

1. I am trying to write an application that will automate Internet
Explorer and store data in a database. Am I better off learning VB.net
or C#.net? Is there a free development environment for C# as well?

2. I have followed examples in other posts and copied this code to
open up IE:

Imports SHDocVw
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim wbBrowser As New SHDocVw.InternetExplorer
wbBrowser.Visible = True
wbBrowser.Navigate("http://www.rediff.com", Nothing, Nothing,
Nothing, Nothing)
End Sub
End Class

These are my errors:

Warning 1 Namespace or type specified in the Imports 'SHDocVw' doesn't
contain any public member or cannot be found. Make sure the namespace
or the type is defined and contains at least one public member. Make
sure the imported element name doesn't use any aliases. C:\Documents
and Settings\Administrator\Local Settings\Application Data\Temporary
Projects\WindowsApplication3\Form1.vb 1 9 WindowsApplication3

Error 2 Type 'SHDocVw.InternetExplorer' is not defined. C:\Documents
and Settings\Administrator\Local Settings\Application Data\Temporary
Projects\WindowsApplication3\Form1.vb 5 30 WindowsApplication3

Can someone please help this newbe?

Do you want to start Internet Explorer or just the user's default web
browser? If you want to start the default browser, use this code
(pulled from MSDN):

Dim myTargetURL As String = "http://www.google.com"
System.Diagnostics.Process.Start(myTargetURL)

If you want to start IE specifically, then do something like this:

Dim myTargetURL As String = "http://www.google.com"
System.Diagnostics.Process.Start("IExplore.exe", myTargetURL)

Hope that helps,

Chuck
 
L

Lloyd Sheen

camainc said:
Do you want to start Internet Explorer or just the user's default web
browser? If you want to start the default browser, use this code
(pulled from MSDN):

Dim myTargetURL As String = "http://www.google.com"
System.Diagnostics.Process.Start(myTargetURL)

If you want to start IE specifically, then do something like this:

Dim myTargetURL As String = "http://www.google.com"
System.Diagnostics.Process.Start("IExplore.exe", myTargetURL)

Hope that helps,

Chuck

If you want to host a browser in your app you can use the WebBrowser
control. It is easy to create buttons to simulate the forward / back
buttons and a textbox for the URL. There are events from this control which
you can capture to update those controls. For example the DocumentCompleted
event will present you with the URL of the last page transmitted.

There are a set of methods available such as Navigate to start browsing to
the string (URL) provided. And other command such as GoHome if you wanted to
provide a button control to do that. I have a full clone of IE with my
extensions working with just a small amount of code.

Good luck and if you have questions I can answer them.

Lloyd Sheen
 
C

Cor Ligthert [MVP]

Etayki,

You need to set a reference to Internet explorer and than an import. It is
always hard to find but it is in the Com tab.

Project -> Add Reference -> Com (I thought just Internet Explorere) but
search yourself it can be a hell of a job by instance because Microsoft uses
irregular the internal and the external names.

There is almost not any difference between using in this VB.Net or C#.

As I saw in your code don't you need in VB.Net that nothing, nothing,
nothing, what can by anoying in C#.
 
L

Lloyd Sheen

Cor Ligthert said:
Etayki,

You need to set a reference to Internet explorer and than an import. It is
always hard to find but it is in the Com tab.

Project -> Add Reference -> Com (I thought just Internet Explorere) but
search yourself it can be a hell of a job by instance because Microsoft
uses irregular the internal and the external names.

There is almost not any difference between using in this VB.Net or C#.

As I saw in your code don't you need in VB.Net that nothing, nothing,
nothing, what can by anoying in C#.

As I pointed out earlier since you are using VB 2005 just use the MS
provided WebBroswer control. No need for COM.

Lloyd Sheen
 
C

Cor Ligthert [MVP]

Lloyd,

In my idea is (seeing the code) direct Internet Explorer used
(SHDocVW.InternetExplorer), not the interop AX Com version.

Can you tell me how you can do that with the 2.0 webbrowser?

Cor
 
L

Lloyd Sheen

Cor Ligthert said:
Lloyd,

In my idea is (seeing the code) direct Internet Explorer used
(SHDocVW.InternetExplorer), not the interop AX Com version.

Can you tell me how you can do that with the 2.0 webbrowser?

Cor
Cor,

In VS 2005 there is a WebBroswer control. It does all that the old interop
would do. I think the poster copied code from somewhere and then added that
to his source. If he had added a reference to the dll holding the WebBrower
(don't know the name right now) it would add the interop to his project. In
VS 2002/3 this is what you did (and in VB6 as well).

All you need to do is add the WebBroswer from the toolbox and all the
events, properties and methods are available. As I said you can recreate IE
in about 10 minutes.

Lloyd Sheen
 
C

Cor Ligthert [MVP]

Lloyd,

I have made about a year ago an article about what you write in the Dutch
dotNet newsgroup, how to make your own tabbed webbrowser and as well how to
build an editer with the webbrowser control.

However there is a use that always everybode who has used this becomes
confused of a guy in this newsgroup had spent almost 50 messages replying
before after seeing my reply he understood it.

You can with the webbrowser COM part build your own webbrowswer, the thing
has the name AXSHVDOCvw, however there is as well
SHVDOCVW,InterenetExplorer. That opens internet explorer for you and you can
use that then.

http://www.vb-tips.com/dbpages.aspx?ID=58514c5a-5f5d-4b6d-a7bd-da738cdc7c2c

Cor
 
E

Etayki

Lloyd,

I have made about a year ago an article about what you write in the Dutch
dotNet newsgroup, how to make your own tabbed webbrowser and as well how to
build an editer with the webbrowser control.

However there is a use that always everybode who has used this becomes
confused of a guy in this newsgroup had spent almost 50 messages replying
before after seeing my reply he understood it.

You can with the webbrowser COM part build your own webbrowswer, the thing
has the name AXSHVDOCvw, however there is as well
SHVDOCVW,InterenetExplorer. That opens internet explorer for you and you can
use that then.

http://www.vb-tips.com/dbpages.aspx?ID=58514c5a-5f5d-4b6d-a7bd-da738c...

Cor

"Lloyd Sheen" <[email protected]> schreef in bericht

Thanks for all the help guys.
Here is the final code:

Imports MSHTML, SHDocVw

Dim HTMLDoc As MSHTML.HTMLDocument
Dim wbBrowser As New SHDocVw.InternetExplorer
Dim iHTMLCol As MSHTML.IHTMLElementCollection
Dim iHTMLEle As MSHTML.IHTMLElement
Dim Str As String

wbBrowser.Visible = True
wbBrowser.Navigate("http://search.msn.com/results.aspx?q=etay+
%7Bpopl%3D0%7D+%7Bmtch%3D100%7D+language%3Ahe+site
%3Aco.il&form=QBRE&go.x=17&go.y=10", Nothing, Nothing, Nothing,
Nothing)
Do
Loop Until Not wbBrowser.Busy

HTMLDoc = wbBrowser.Document
iHTMLCol = HTMLDoc.getElementsByTagName("input")
For Each iHTMLEle In iHTMLCol
If Not iHTMLEle.getAttribute("name") Is Nothing Then
Str = iHTMLEle.getAttribute("name").ToString
If Str = "q" Then
iHTMLEle.setAttribute("value", "×יתי" + " {popl=0}
{mtch=100} language:he site:co.il")
Exit For
End If
End If
Next
Do
Loop Until Not wbBrowser.Busy

For Each iHTMLEle In iHTMLCol
If Not iHTMLEle.getAttribute("name") Is Nothing Then
Str = iHTMLEle.getAttribute("name").ToString
If Str = "go" Then
iHTMLEle.click()
Exit For
End If
End If
Next
Do
Loop Until Not wbBrowser.Busy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top