Results 1 to 6 of 6

Thread: vb 6.0 create hyperlink

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    8

    vb 6.0 create hyperlink

    Hi, i am trying to make a simple .exe file, just with different buttons on it. I want to be able to click a button, and have it take me to a specific webpage. I created the template, just dont know how to direct it to a hyperlink. Any sugestions?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: vb 6.0 create hyperlink

    Welcome to the Forums.

    ShellExecute the link in the buttons click event.

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    4.                     ByVal hwnd As Long, _
    5.                     ByVal lpOperation As String, _
    6.                     ByVal lpFile As String, _
    7.                     ByVal lpParameters As String, _
    8.                     ByVal lpDirectory As String, _
    9.                     ByVal nShowCmd As Long) As Long
    10.  
    11. Private Const SW_SHOWNORMAL As Long = 1
    12.  
    13. Private Sub Command1_Click()
    14.     ShellExecute Me.hwnd, "Open", "http://vbforums.com", vbNullString, "C:\", SW_SHOWNORMAL
    15. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    8

    Re: vb 6.0 create hyperlink

    wow pretty cool, I got it to work. Thanks so much for ur help robdog- The only other thing I would like to do (if possable) I would like to have it so if I have a webpage open but minimized, and then click a specific button in the project I made, instead of changing the minimized internet explorer page to the new link (from pressing the button I made) I would like it to open a new page. Is it hard to modify it to do that? if so, its not critical, the main thing is to set up a page with different buttons on it, which I just completed. Thanks once again for ur help.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: vb 6.0 create hyperlink

    Well, the ShellExecute trick shown above will simply look at what you're trying to open (an URL in this case) and then look in the Windows Registry after a program that is associated to do so. In this case it will find that an Internet browser is to be used (IE, Firefox, Netscape, or whatever you use as your default browser). So you don't really control it.

    You can force, for example, a new instance of Internet Explorer to open and show the page in question, but do you think a user that loves Firefox and use that as his default browser really would appreciate that?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: vb 6.0 create hyperlink

    If you need to control the content of the opened web page then perhaps using the web browser control on a form will be best.

    Check out this thread for examples on that logic.
    http://www.vbforums.com/showthread.php?t=330341
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    372

    Re: vb 6.0 create hyperlink

    you can usually force a new browser by clicking a shortcut. i belive that is the default behavoir.

    save a file with the url in it + a shortcut header as somthing.url.

    that just shell the new file, and viola, a new browser window.
    for example
    open notepade and paste the code below into it, and save it with a .url extention. then double click the file.

    i suppose you could also shellexecute the .url file...

    [InternetShortcut]
    URL=http://www.vbforums.com/showthread.php?t=455043


    ok, i missed a bus, so i have some more time.
    this should do it all:

    Public Sub dourl(theurl)
    Dim ff As Integer
    ff = FreeFile
    dim sFileName As String
    sfilename=environ$("temp") & "\urltmp.tmp"
    dim FileContent As String
    filecontent="[InternetShortcut]" & vbcrlf & theurl

    Open sFileName For Output As #ff
    Print #ff, FileContent;
    Close #ff

    call shell ( "%comspec% /c " & sFileName )
    End Sub

    didnt test, but should get you goin...

    another happy side effect it that it uses the users browser of choice to run...

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