473,396 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Execute other Program...

On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?
Jul 17 '05 #1
12 8068
If that's all that's in that textbox, then the solution is simple... just
set up
a CLICK event on the textbox, that passes it's contents to a SHELLEXECUTE
API call. Over here, I have this API call pre-defined as "runfile" in a
module called "shellexec", so in this situation, I would only need to do...

Private Sub Text1_Click()
ShellExec.RunFile Text1.Text
End Sub

"Scott D. Barrish" <sb******@tampabay.rr.com> wrote in message
news:iH*****************@twister.tampabay.rr.com.. .
On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?

Jul 17 '05 #2
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,
vbMaximizedFocus)

Sincerely,
Scott D. Barrish
Jul 17 '05 #3
On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,
vbMaximizedFocus)


It might be an idea to programatically find the file name and location
of the default browser

The API FindExecutable() is useful for that
Jul 17 '05 #4
I used the following code:

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

Private Sub lbl_Link_Click()
Dim r As Long
r = ShellExecute(0, "open", lbl_Link.Caption,0, 0, 1)
End Sub
"J French" <er*****@nowhere.com> wrote in message
news:3f**************@news.btclick.com...
On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
Thank you for your help.

I accomplished my task with the following:

Shell("c:\program files\internet explorer\iexplore.exe " & lblLink.Caption,vbMaximizedFocus)


It might be an idea to programatically find the file name and location
of the default browser

The API FindExecutable() is useful for that

Jul 17 '05 #5
On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
I used the following code:

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


Yes, that is fine - provided one small thing ....

That you are sure that ShellExecute will recognize the 'file' that you
are sending it

Having to launch a browser to try to go to all sorts of dubiously
formatted web addresses, I opt for finding the App's name and then
launching it myself

That way I am sure a Browser will get launched ...

Think about it for a bit ...
- I spent some time worrying over the problem

Of course FindExecutable is fundamentally faulty, as it might launch a
DDE server - and also (stupidly) needs an existing file
- but give it c:\temp\dummy.htm and it comes back with a browser

- the other (safe) method is to ponce around in the registry looking
for the file associated with 'htm'
- having nailed that down once, I don't like using it
Jul 17 '05 #6
xyz
On Wed, 24 Sep 2003 12:00:14 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
On my form, I have a field that displays the student's website. How do I
display thewebsite as a hyperlink in a textbox where the user can click on
it and Internet Explorer opens up the site?


====================
I recently had to solve this problem. It is different for Windows
95,98,ME and Windows NT,2000,XP. Here is a cross-system solution.

Place a "Microsoft SysInfo control" on your form. Set the "label"
field that displays the web site URL to be underlined in the Font
attribute, set the MousePointer attribute to 99 (custom), and set the
MouseIcon to HAND-M.CUR (it is normally in the /windows/cursors
directory, I attached it). This will cause the web hand to show when
the cursor is placed over the label that has the web link.
' The declaration below goes in a Module1.bas file
' execute shell command
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
' This is the code to launch the browser (It assumes that
' the form with the SysInfo control is frmMain
Private Sub Label5_Click()

Dim rcu As Long
Dim URL As String
' ShellExecute defined in Module1.bas

URL = "http://www.yahoo.com/" ' or whatever

If frmMain.SysInfo1.OSPlatform = 2 Then
' OSPlatform = 2 for Win NT/2000/XP
Call ShellExecute(Me.hwnd, "open", URL, "", "", 0)
Else
' OSPlatform = 1 for Win 95/98/ME
rcu = Shell("start " & URL, vbNormalFocus)
End If
End Sub


Jul 17 '05 #7
xyz


Jul 17 '05 #8
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,
as you say. However I dont I dont know how :-)

A.

"J French" <er*****@nowhere.com> wrote in message
news:3f**************@news.btclick.com...
On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
<sb******@tampabay.rr.com> wrote:
I used the following code:

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


Yes, that is fine - provided one small thing ....

That you are sure that ShellExecute will recognize the 'file' that you
are sending it

Having to launch a browser to try to go to all sorts of dubiously
formatted web addresses, I opt for finding the App's name and then
launching it myself

That way I am sure a Browser will get launched ...

Think about it for a bit ...
- I spent some time worrying over the problem

Of course FindExecutable is fundamentally faulty, as it might launch a
DDE server - and also (stupidly) needs an existing file
- but give it c:\temp\dummy.htm and it comes back with a browser

- the other (safe) method is to ponce around in the registry looking
for the file associated with 'htm'
- having nailed that down once, I don't like using it

Jul 17 '05 #9
On Fri, 26 Sep 2003 20:48:50 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,
as you say. However I dont I dont know how :-)

1) ShellExecute() finds and runs the browser

2) FindExecutable() finds the browser - you need to run it (good)

3) Peer into the Registry - Ok - but can be tedious

Jul 17 '05 #10
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

FindExecutable

Finds the file name of the program that is associated with a specified file.
The Windows registration editor can be used to associate types of files with
particular applications. For example, text files that have the extension
..TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).

Cheers

"J French" <er*****@nowhere.com> wrote in message
news:3f***************@news.btclick.com...
On Fri, 26 Sep 2003 20:48:50 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
Iexplorer.exe is not the only browser out there.

I think one should try to locate the browser associated with the htm files,as you say. However I dont I dont know how :-)

1) ShellExecute() finds and runs the browser

2) FindExecutable() finds the browser - you need to run it (good)

3) Peer into the Registry - Ok - but can be tedious

Jul 17 '05 #11
On Sat, 27 Sep 2003 09:21:58 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

FindExecutable

Finds the file name of the program that is associated with a specified file.
The Windows registration editor can be used to associate types of files with
particular applications. For example, text files that have the extension
.TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).


The only 'gotcha' is that you have to give it the name of a file that
actually exists.

So if I want to go to 'www.borland.com'
then I create a file called : 'c:\temp\dummy.htm'

Use FindExecutable() to find the EXE for 'c:\temp\dummy.htm'
Then launch that EXE with the 'real' target in the command line

A bit silly of MS to make the file have to exist, but there are some
legacy DDE considerations that I've chosen to ignore.
Jul 17 '05 #12
On Sat, 27 Sep 2003 09:21:58 +0300, "Aristotelis E. Charalampakis"
<ar***********************@REMOVEMEhotmail.com> wrote:
mmm, of course you are right.

Should have checked before opening my mouth. I wasnt aware of this api, but
appleman is clear:

Dunno, by asking you've found something fairly obscure ...

Oops - I meant to post this

This link might also be useful :-

Obtaining the Path and Filename of the Default Browser
http://www.mvps.org/vbnet/code/filea...erfilename.htm
Jul 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
1
by: Thomas | last post by:
Hi all, I want to execute a new program in a c++ program without beeing blocked. After the child process is created both processes should run idependend. My method at the moment: execute(...
3
by: Lubos | last post by:
Hi, How can i make this. When i maked a program in C# and then when the program is execute on computer without .NET Framework, how can i automaticaly invoke instalation of Framework after execute...
4
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service...
2
by: joe1977 | last post by:
Win2k3, PHP 5, Apache 2, Acrobat 7 when I go to my server, pull out cmd.exe and type as follows: "c:\Program Files\Adobe\Acrobat 7.0\\Reader\AcroRd32.exe" /t "c:\Program Files\Adobe\Acrobat...
0
by: wolf2300 | last post by:
hi how can i remotly execute program . i have 2 computers A and B . on both of them i have aplication (myap.exe) myap require 2 parameters. First is mypath , 2 myfile. for example to execute i...
3
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
I have a .NET VC++ program, I want to execute some dos command from the program, e.g. copy some file, and etc. How do I do that?
2
fungazid
by: fungazid | last post by:
Help help help please I’m using DBD::mysql, and I want to insert a record into clients table (id, address, and phone-number of a client): my $str= “?,?,?,,,”; my...
6
by: moongeegee | last post by:
I have compile my java program as myjava.class. And I can run as "java myjava" without any program. As now, I need to execute myjava.class in javascript. Please shed a light how to execut "java...
5
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.