Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post

    [vb] How do you open an IE window with vb

    Hey,

    I would like to know how I can get vb to open an internet explorer (or even better the default browser) with vb. I have done alot of googling into this matter but what I find doesnt work so I figuried Id ask here. I know that vb has a built in browser and Im using i currently but what im wanting to do requires a browser outside of the program, also it would help a great deal if I could open it at a certain size so that I could have the program that opened it visible as well. Here is some code that I found on the net, the only thing is when I click the button it does nothing, I had to make a reference to the Microsoft internet controls to get it to even run.

    Code:
    Public ie as InternetExplorer
    Private Sub Command1_Click()
       Set ie = CreateObject("InternetExplorer.Application")
       ie.Navigate2 "http://visualbasic.about.com"
    End Sub
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There was something i tried once. Don't remember the code offhand and i don't have vb on this machine...
    I had a page1 on my system which pops up page2 (using vbscript or javascript) when loaded. I used VB's browser control on the form and set it to invisible. It was something like this

    Form Loads > browser control loads page1 > page1 pops open page2

    Page2 opens in the default browser.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For the code you posted I'm guessing you need to find a method to make the application visible (Show or something like that).
    Have you tried using the Win32 API function ShellExecute? I think it would open the default browser. Controlling the size of the browser you open with it would be tricky and I imagine you would need to use other Win32 functions to control that (FindWindow, etc.).

    shmoove

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    From what it sounds like Tboos, your method wouldnt work for me, I need something like in the code I posted that stores the instance of IE as a variable so I can pass information to the window thru the variable. As for shmoove, the Show property can't be used on the IE thing, gives me an error, and nothing else that It could use seemed to do the trick. I have not used the api functions cuz I really dont know em but Ill look into that later on today I suppose.
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    Your in luck, im useing the same type of thing for a project im on now

    Here, use my code. It opens athe default browser with whatever you want, am not sure about how to specify the size tho, maybe someone here can edit it

    PHP Code:
    Option Explicit
    Browser Command
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                             
    (ByVal hwnd As LongByVal lpOperation As String_
                              ByVal lpFile 
    As StringByVal lpParameters As String_
                              ByVal lpDirectory 
    As StringByVal nShowCmd As Long) As Long

    Private Const SW_NORMAL 1

    Private Sub cmdBrowser_Click()

        If 
    txtAddBar.Text "http://www." Then
        msgError 
    MsgBox("Please enter a valid URL."64"Error")
    Else
        
    blocation txtAddBar.Text
        ShellExecute Me
    .hwndvbNullString_
                     blocation
    vbNullString_
                     
    "C:\", SW_NORMAL
        txtAddBar.Text = "
    http://www."
    End If
    End Sub 
    Make a text box called "txtAddBar" and your set. This will take whateva is typed in a text box and open it in a default browser. Also make a button called "cmdBrowser", lol nearly forgot about that one.

    If you want it to not have a text box, im sure ppl can edit it here, if not ill do it on request . Enjoy

    *EDIT*

    After reading your post, i see you do want it to open a specific webpage so use this code instaed. I'll leave that one there abouve incase anyone else needs it.

    Use the same code as above, but for your button use this code:

    PHP Code:
    Private Sub Command1_Click()
        
    ShellExecute Me.hwndvbNullString_
                     
    "http://visualbasic.about.com"vbNullString_
                     
    "C:\", SW_NORMAL
    End Sub 
    Last edited by Anthony2oo4; 02-11-2005 at 09:06 PM.

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    This thread is your friend: http://www.vbforums.com/showthread.p...hreadid=213415 A great list of APIs to be used with VB.
    OracleGuy

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    I appreciate your help as well but I dont think it will work either, I tried it out and all it does for me is open the default browser. Ill try and explain a bit more on what im attempting to achieve. I have a program already that sends commands to the built in browser that vb has, here is an example of the code that will send a serach value into googles serach box and search for it.

    Code:
    wbBrowser.Document.getElementsByName("q").Item(0).Value = "Coding Forums"
    wbBrowser.Document.getElementsByName("btng").Item(0).Click
    Im just trying to move away from the built in browser to the users default because it would be far more convienent for me and them and would open a few more windows for me to improve my existing program. I did look into the shellexecute stuff and have gotten it to open internet explorer, tho im sure it can be set so the user can pick, the only thing is that doesnt do what im looking for either.
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #8
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    I dont know if I full understand what you mean, is this the only thing you wanna throw over to the browser?

    If so then why not try this:

    PHP Code:
    Private Sub Command1_Click()
    Dim gsearch As String
    gsearch 
    "http://www.google.co.uk/search?hl=en&q=" Text1.Text
        ShellExecute Me
    .hwndvbNullString_
                     gsearch
    vbNullString_
                     
    "C:\", SW_NORMAL
    End Sub 
    Just simply make a text box and a command button.

    If am wrong then im sorry i dont understand, can I have your project files to see more detail?

    Thanks

  • #9
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    I could give you the project files, the thing is this is my first really big progam (over 6000 lines, prolly 50% overkill ) and its something that is highly coveted in the game I play, kings of chaos, it is an autobuyer and I dont really want it to fall into the wrong hands but if you really want it ill pm you the url to download the project.

    EDIT: bah ill just post it here
    Last edited by Bry Man; 02-13-2005 at 06:06 AM.
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #10
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    I keep getting an error with this line

    Code:
    BuyVal1 = txtBuy1.Text
    So i cant explore the program much

  • #11
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    Ya I just recently put all the stuff onto that tabbed thing so that may have messed it up a bit because I copyed the stuff deleted the ld stuff and re-pasted it onto the tabs. Also you have to be authorized to use the program or it wont work, also the site that I have the auth file on is down so you couldnt use it if you were authorized....ill put up the older untabbed version for you then. If you want to use it fully youll have to create an account on kings of chaos and tell me your name so I can authorize you when the sites back up. I am having a slight problem with it not filling in the site before moving on which should not happen but it will give a type mismatch error 91 on occasion, but it does work.
    Last edited by Bry Man; 02-13-2005 at 06:06 AM.
    When traveling down the road of life, Try not to drag your face in the gravel.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •