|
-
Jan 20th, 2007, 06:29 AM
#1
Thread Starter
Junior Member
Adding web links to a form
Hi all,
I would like to get the web links from a database and display on the form. When the user clicks the link Internet Explorer opens and goes to the link. Do you know how I can do this? In which tool box element must I put the link content ? (label or what? it is not label but what then )
Thank you
-
Jan 20th, 2007, 02:04 PM
#2
Re: Adding web links to a form
Based on your other posts I see you are using VB - which is not the same as VBScript, so I have moved this thread from the ASP/VB Script forum.
You can use any control you like for this.. none of them actually do the work for you, but it is easy enough to add it yourself.
The way to do it is shown in the thread How do I open a file/web-page in its default application? from our Classic VB FAQ's (link in my signature).
-
Jan 20th, 2007, 02:21 PM
#3
Re: Adding web links to a form
What you do to make it look like a link is....
1) Add a Label, call it "lblLink"
2) Change the Font of the link to the color Blue, and add underline
3) Double click it and add the code:
VB Code:
'in General-Declarations:
Private 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
'Example code:
'open a file
ShellExecute Me.hWnd, "open", "c:\My folder\Test.doc", vbNullString, "C:\", ByVal 1&
'open a web page
ShellExecute Me.hWnd, "open", "http://www.VBForums.com", vbNullString, "C:\", ByVal 1&
My usual boring signature: Something
-
Jan 20th, 2007, 06:15 PM
#4
Thread Starter
Junior Member
Re: Adding web links to a form
It is going to be a loop and will get the web sites from a database? Does it make a difference?
-
Jan 20th, 2007, 06:39 PM
#5
Re: Adding web links to a form
That's fine, and actually irrelevant.. once the address is in your program (in a variable or control), you can open the page.
To open the web page you just need to pass the address to OpenURL (if you are using the Sub from the FAQ thread), or put it in place of the hard-coded address if you are using the part of the FAQ that dclamp re-posted.
If you have the OpenURL sub and the address is in Label1.Caption, you can simply use this:
-
Jan 20th, 2007, 07:04 PM
#6
Re: Adding web links to a form
You may also want to change your mouse icon to a hand sorta link.
-
Jan 20th, 2007, 07:43 PM
#7
Re: Adding web links to a form
 Originally Posted by zynder
You may also want to change your mouse icon to a hand sorta link.
Yea
You can use your own custom cursor or find them in %windir%\cursors (C:\Windows\Cursors)
Just set the label's MouseIcon property to the cursor file, and it's MousePointer property to 'Custom'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|