Solved

WebBrowser

Posted on 1998-12-16
13
149 Views
Last Modified: 2010-05-03
Hi,

I have the following question:

I want the user to be able to browse some sites in the internet.  That's mean, In my Visual Basic Program I want to have a link that takes me to the corresponding website.

But I wrote many codes but unforunately, I did not succeed. Really, I need your help.  I know this question is not easy I believe one of our experts can.

So Please HELP ME.

Thank you.
0
Comment
Question by:lovely_bird
  • 5
  • 4
  • 3
  • +1
13 Comments
 

Author Comment

by:lovely_bird
ID: 1450578
Please help me!!!!!!!!!!!!
0
 
LVL 2

Expert Comment

by:spenner
ID: 1450579
Do you mean you want to be able to click on something, and launch the default browser to a specified web site, or do you want the default browser to be run and you control it from your vb program while it's running?

0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1450580
If you use the application setup wizard in the very beginning of your project, it will ask you if you want to include a web browser in your application to connect to sites.  That will build the browser for you (mostly).  Try giving that a try.
0
 
LVL 1

Accepted Solution

by:
YiannisVolos earned 100 total points
ID: 1450581
Hello there.
Actually it can be achieved without any complex code...
Create a simple command button and at the code where is clicked, double clicked or what ever enter similar code to this...

i = Shell("C:\progra~1\internet explorer\iexplore.exe http://www.gameproc.com", vbNormalFocus)

This code uses the command shell which begins a new thread of a program. In this example, Internet Explorer. The basic problem is that you should have Internet Explorer and know the directory...But you could very easily achieve that also with a simple use of the command dir.
There is a possibility that this can work with Netscape Navigator.

However what you want to do may be achived by using Microsoft webbrowser OCX which exists only if someone has IE installed or if you distribute with your app. I think you are allowed...
Anyway, this way you can have a build-in browser in your application!

Good luck.

Regards,
Yiannis
0
 

Author Comment

by:lovely_bird
ID: 1450582
Hi Yiannis,
Thank you for your excellent answer.  But I have another question for you:

The current program that I am developing, when I finish it, I will make an executable file that can be run from any computer so, Imagine that I run this *.exe file on a computer that :
1. does not have an internet connection.
2. have an internet connection with a different path than what my computer (original) have

Does my program work propabley on both computers.  I beleive that the first case the program will not work.  but what about the second case.

Thank you very much Yiannis.
Waiting for your reply.

0
 

Author Comment

by:lovely_bird
ID: 1450583

     Thank you for your excellent answer.  But I have another question for you:

     The current program that I am developing, when I finish it, I will make an
     executable file that can be run from any computer so, Imagine that I run this
     *.exe file on a computer that :
     1. does not have an internet connection.
     2. have an internet connection with a different path than what my computer
     (original) have

     Does my program work propabley on both computers.  I beleive that the first
     case the program will not work.  but what about the second case.

     Thank you very much Yiannis.
     Waiting for your reply.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:YiannisVolos
ID: 1450584
Hello again...
Thanks for the points!

Well, it will work in both cases. That means it does not matter if your program runs a programs without an internet connection. However you should find the path of Internet Explorer's or you could ask the user to write it down and you could save it in the registry or in a file...

Regards,
Yiannis

0
 

Author Comment

by:lovely_bird
ID: 1450585
Hi also again,
I think you did not understand my question.  I plan to put my VB program once I finish it on a CD Rom Disk, so you may use it also.  What I understand from you that I have to ask every one that will use my program or what.  How many shall I ask.
I like the method you tell me to use.  But I think I will be only able to connect to this site in the Internet because my Internet Explorer is locatted on my D:\ Drive.  So if someone has the Internet Explorer installed on the C:\ Drive this part of my program will not work, which I think it is NOT a good idea.
So what shall I do, please help me.
I am sorry for that but it seems to me that you are the only expert who understand me.
Thank you and I am waiting for your reply ASAP.
Thank you.
0
 
LVL 1

Expert Comment

by:YiannisVolos
ID: 1450586
Hello again...
You seem you didnt understand how to use the command Shell...
My previews comment sais that you should either ask the user to enter the path of internet explorer and save it somewhere so you wont have to ask it again or seek it by yourself...

Example 1: Typing the path and saving it in the registry.
Lets assume that you have an options dialog where you have a txtbox called IEpath. The user now types the path but you want to save it...
After the user has pressed a button called OK, Apply or whatever you should add this code to save the information typed in the registry...

SaveSetting "MyApplication", "Options", "IE Path", IEpath.txt

Now the user goes at the About section of your program and you have their e.g. a button that is clicked and transfers you at the website...

At the button's source code type...
gotIEpath = GetSetting ("MyApplication", "Options", "IE Path")

i= Shell(gotIEpath+"iexplore.exe", VbNormalFocus)

(Within the path you could save and the name of the file so that you wont have to type '+ "iexplore.exe")

Please look up the syntax of the SaveSetting and GetSetting commands at your VB's help...

You can use Dir and find the path where iexplore.exe exists...

Regards,
Yiannis
0
 
LVL 2

Expert Comment

by:spenner
ID: 1450587
Why not just open the default browser (the program associated with html files), or use
Shell ("Start http:\\www.infoseek.com")
0
 
LVL 2

Expert Comment

by:spenner
ID: 1450588
Why not just open the default browser (the program associated with html files), or use
Shell ("Start http:\\www.infoseek.com")

To get the default browser - use

'@@@@@@@@ Insert this Code into a Module @@@@@@@@

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
   (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
   ByVal lpParameters As String, ByVal lpDirectory As String, _
   ByVal nShowCmd As Long) As Long
   
Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
   (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As _
   String) As Long

' *******************************************************************
' Figure out what the user's default browser is
'
Private Sub DoBrowser(OutputFile As String)
   Dim FileName As String, Dummy As String
   Dim BrowserExec As String * 255
   Dim RetVal As Long
   Dim Filenumber As Integer
   Const SW_SHOWNORMAL = 1                   ' Restores Window if Minimized
   
   BrowserExec = Space(255)
   FileName = "C:\temphtm.HTM"
   
   Filenumber = FreeFile()                   ' Get unused file number
   
   Open FileName For Output As #Filenumber   ' Create temp HTML file
      Write #Filenumber, " <\HTML>"          ' Output text
   Close #Filenumber                         ' Close file
   
   ' Then find the application associated with it.
   RetVal = FindExecutable(FileName, Dummy, BrowserExec)
   BrowserExec = Trim$(BrowserExec)
   ' If an application is found, launch it!
   If RetVal <= 32 Or IsEmpty(BrowserExec) Then    ' Error
       MsgBox "Could not find a browser"
   
   Else
      RetVal = ShellExecute(frmMain.hwnd, "open", BrowserExec, _
         OutputFile, Dummy, SW_SHOWNORMAL)
      If RetVal <= 32 Then                   ' Error
         MsgBox "Page not opened"
      End If
   End If
   
   Kill FileName                             ' delete temp HTML file
   
End Sub


'@@@@@@@@ Insert this Code into a Form @@@@@@@@


DoBrowser "http:\\www.infoseek.com"
0
 

Author Comment

by:lovely_bird
ID: 1450589
Hi spenner & YiannisVolos,
Thank you for taking the time to answer my question.  But I used spenner's method which is only write: Shell ("Start http:\\www.infoseek.com") and it works with me fine.
I want to ask is this only works with Internet Explorer Or it depends on our defualt browser?
Thank you again and sorry for bothering you.
Lovely Bird.
0
 
LVL 2

Expert Comment

by:spenner
ID: 1450590
It works for whatever the default browser is I believe.  It's as if you typed the web address in the run box in the start menu
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now