CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    Open Internet Site

    I have created an ABOUT BOX for my new program, and have created a command button which, when clicked, I would like it to open a web page. Does anyone know what code I would use?

    Please help - I am a COMPLETE beginner!


  2. #2
    Join Date
    Mar 2000
    Location
    Japan
    Posts
    134

    Re: Open Internet Site

    Use shell function.

    Like

    shell("c:\windows\explorer http://" & mysite) ' where mysite is any valid url




    Hope it will solve your problem

    e-mail : [email protected]

    Webmaster of (Code Master)

  3. #3
    Join Date
    May 2000
    Posts
    35

    Re: Open Internet Site

    A slightly better approach would be to use the ShellExecute API, because it understands file associations, it will open whichever browser a user has as the default browser.

    Place the following code in the General Declarations of a module:

    Public 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
    Public Const SW_SHOW = 5




    Then open the URL like this:

    ShellExecute 0, "open", "http://www.yahoo.com", vbNullString, vbNullString, SW_SHOW




    Hope this helps,
    Chris


  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Open Internet Site

    You can use the control from :

    http://codeguru.developer.com/vb/articles/2070.shtml

    - it wraps up all the shellexecute api calls for you and allows you to specify 'behaviour' of the 'url' - all the source code and a sample project is included.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  5. #5
    Join Date
    May 2000
    Location
    ASU, Tempe, AZ
    Posts
    2

    Re: Open Internet Site

    Very thorough job! Congratulations on a masterful piece of work! I have been researching a
    similar question, and this showed me how much was involved.

    Thanks.


    Cliff Sather

  6. #6
    Guest

    Re: Open Internet Site

    Thanks everyone!


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured