Click to See Complete Forum and Search --> : Url link in a label


Anchor Blue
January 6th, 2000, 05:02 PM
How would you put a Url link, so the user can click on it and it takes them to the url of the link?

Chris Eastwood
January 6th, 2000, 05:16 PM
Karl Peterson has a good (free with code) usercontrol (called HyperLabel ?) for download on his site at http://www.mvps.org/vb - I think it comes with a sample project also.

Chris Eastwood

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

January 6th, 2000, 07:59 PM
i suppose if you want to do that, then you need more code with it:

you have to have a way to check if the user is hooked up to the internet.
the user must have a browser (IE 4, NE 4)

you could, as a desperate attempt, open IE 4, use a SendKeys function to send the label to it, and then sendkeys enter...this is a last attempt

you can find the codes for hooked up to the internet in www.vbcode.com - there are several of them.
there is a code which you can see if a fileexists there too, it is vbhelper.

Chris Eastwood
January 7th, 2000, 02:40 AM
A simple way of opening a browser window with a specified URL is as follows :


'
' Place this declare in a BAS / CLS / FRM module as appropriate
' not forgetting to change public to private where required !
'
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 Sub ExecuteLink(byval sLinkTo as string)
'
' Execute the passed Link
'
on error resume next
'
Dim lRet as Long
Dim lOldCursor as Long
'
lOldCursor = Screen.MousePointer
'
Screen.MousePointer = vbHourglass
'
lRet = ShellExecute(0, "open", sLinkTo, "", vbNull, SW_SHOWNORMAL)
'
If lRet >= 0 And lRet <= 0 then
Screen.MousePointer = vbDefault
MsgBox "error Opening Link to " & sLinkTo & vbCrLf & _
vbCrLf & Err.LastDllError, , "ExecuteLink"
End If
Screen.MousePointer = vbDefault
'
End Sub




This allows you to call the 'ExecuteLink' routine in ways such as :


ExecuteLink "http://codeguru.developer.com/vb"
'
' or
'
ExecuteLink "mailto:chris.eastwood@codeguru.com"




The MSDN has a huge article somewhere that shows how to detect what your default browser is (if any) and also how to detect if you are connected to the internet (can't remember the URL's off the top of my head though).


Chris Eastwood

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

wilton
January 7th, 2000, 03:32 AM
I'm not putting anybody down in any way, but I love it when people post saying:
"yeah, I know of something like that. I think it's called &*&^%, but I don't remember where I found it."

Well, I think it's funny.