Results 1 to 7 of 7

Thread: how to open a website when we click command button?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    VIETNAM
    Posts
    209

    how to open a website when we click command button?

    Please tell me how to open a website ,e.g :www.vbforums.com when we click the command button on the program?
    Thank you very much!!!

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Again, this should be in the other parts of the Forums (General VB Questions).

    Also, try to include all of your questions in ONE POST.

    VB Code:
    1. Shell "iexplore [url]http://www.vbforums.com[/url]", vbMaximized

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    This code will ensure the website is openend in a new browser window. Only works for IE though...

    VB Code:
    1. On Error Resume Next
    2.  
    3.     Dim Temp As Object
    4.    
    5.     'Create instance
    6.     Set Temp = CreateObject("InternetExplorer.Application")
    7.    
    8.     'Open URL
    9.     Temp.Navigate2 "http://fox.acky.net"
    10.     Temp.Visible = True

    (If the code fails you could try Netscape and the others...)

  4. #4
    Junior Member
    Join Date
    Feb 2003
    Location
    Sweden
    Posts
    27
    This sub opens a link in the default browser. I hope it helps!



    VB Code:
    1. Private Sub openUrl(sLink As String)
    2.     Dim lPath As Long
    3.     Dim sPath As String
    4.     Dim sTempPath As String
    5.     Dim iFile As Integer
    6.  
    7.     If Me.Tag = "" Then
    8.         If Dir(App.Path & "\Temp.htm") = vbNullString Then
    9.             iFile = FreeFile
    10.             Open App.Path & "\Temp.htm" For Output As iFile
    11.             Close iFile
    12.             Me.Tag = Left(sPath, FindExecutable(App.Path & "\Temp.htm", "", ByVal sPath))
    13.             Kill sTempPath & "Temp.htm"
    14.         Else
    15.             Me.Tag = Left(sPath, FindExecutable(App.Path & "\Temp.htm", "", ByVal sPath))
    16.         End If
    17.        
    18.     End If
    19.     If Len(Me.Tag) Then
    20.         ShellExecute 0, "OPEN", Me.Tag, sLink, "", 1
    21.     End If
    22. End Sub

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    The declarations for henrikf's code :

    VB Code:
    1. Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
    2. 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


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    Junior Member
    Join Date
    Feb 2003
    Location
    Sweden
    Posts
    27
    Sorry, I missed those.

  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Originally posted by henrikf
    Sorry, I missed those.
    Don't worry about it. I just figured I'd mention them


    Has someone helped you? Then you can Rate their helpful post.

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