Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

putting url link on a form

Posted on 1998-07-11
8
153 Views
Last Modified: 2010-05-03
how can i put url link on a form or command button
to my homepage
0
Comment
Question by:Glynn071198
8 Comments
 
LVL 1

Expert Comment

by:Jason_G
ID: 1465505
Hi Glynn,
I believe what you are looking for here is the Hyperlink object.  Using the properties and methods of the Hyperlink object, your ActiveX document or ActiveX control can request a hyperlink-aware container, such as Microsoft Internet Explorer, to jump to a given URL.

You can use the NavigateTo method to jump to a URL. For example, the following code presumes an ActiveX document named "axdMyDoc" exists:
UserDocument.Hyperlink.NavigateTo _
"c:\mydocs\axdmydoc.vbd"
      
If your ActiveX document is contained by a hyperlink-aware container (such as Internet Explorer), and if the container maintains a history of documents, use the GoBack or GoForward methods to go backwards or forwards through the list. However, be sure to use error-checking, as shown in the example below:
Private Sub cmdGoForward_Click()
      On Error GoTo noDocInHistory
      UserDocument.Hyperlink.GoForward
      Exit Sub
noDocInHistory:
      Resume Next
End Sub

The syntax for using the NavigateTo method is as follows.

object.NavigateTo Target [, Location [, FrameName]]

The NavigateTo method syntax has these parts:

Part - Description

object - An object expression that evaluates to an object in the Applies To list.

Target - A string expression specifying the location to jump to. This can be a document or a URL.

Location - A string expression specifying the location within the URL specified in Target to jump to. If Location is not specified, the default document will be jumped to.

FrameName - A string expression specifying the frame within the URL specified in Target to jump to. If FrameName is not specified, the default frame will be jumped to.

Also, if the object is in a container that supports OLE hyperlinking, then the container will jump to the specified location. If the object is in a container that does not support OLE hyperlinking, then an application that is registered as supporting hyperlinking is started to handle the request.
If Target does not specify a valid location, an error is raised.

I hope this helps you.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com
0
 

Author Comment

by:Glynn071198
ID: 1465506
thanks jason for for your help but im just a beginer and you lost me when you got to activeX controls. is there a simpler way? i really need some sample code to study. any suggestions on where i might find info.

0
 
LVL 2

Expert Comment

by:rayb
ID: 1465507
Here's an easy method:

In your forms declarations add this:
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

Place a label on a form.
In the OnClick handler for the label, put something like this:
nResult= ShellExecute( null, "open", "http://www.yourlink.com", "", "", 5)

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Glynn071198
ID: 1465508
dear rayb,
tryed pasting code in declaration and got this error:
(Constants, fixed length strings, arrays and declare statments
not allowed as public members of class or form modules.)
did i do something wrong?

ps, would like to run commamd from button or in menu
0
 

Author Comment

by:Glynn071198
ID: 1465509
found something that works using the start.exe in windows\command directory

nResult = Shell("start.exe http://www.nascar.com", vbHide)

if you find something else let me know thanks
0
 
LVL 4

Expert Comment

by:tomook
ID: 1465510
You will have better luck with ShellExecute in the long run, and the Hyperlink object in the longer run. As to ShellExecute, "Public Declares" are allowed only in regular modules. Put the declaration in a regular module or declare it "Private" in your form. Maybe Jason_G could give you some help on installing the Hyperlink control.
0
 
LVL 1

Accepted Solution

by:
movieguy earned 50 total points
ID: 1465511
In your project add the following to a module

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


Where every you want the action to take place like when you choose a menu or click a button add the following.

Call ShellExecute(Me.hWnd, "open", "http://www.address.com", "", "", 5)

I have used this code in menus, buttons, and in label click events and it works in vb5.

0
 

Author Comment

by:Glynn071198
ID: 1465512
works great thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question