Solved

VB3: Access web site URL from program

Posted on 1998-06-18
6
478 Views
Last Modified: 2012-06-21
I would like to open the default browser and go to my web site (or any other URL) from my program (VB3).  I tried using"
ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)

(by the way, where is vbNullString defined? I would think this would give me an undefined error)

This worked at home.  I came in to work and tried it and the shellexecute returns a 2 (could not find file, i think, what file?) and does not open IE.

Thanks in advance,
Rob
0
Comment
Question by:RentRight
[X]
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
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1463726
Check if you have assosiation for .html files
0
 
LVL 1

Expert Comment

by:cip
ID: 1463727
If you're working with Windows NT, 16 bit ShellExecute will give error code 2 if the associated executable file exists in a directory path containing a long file name. This happens only on Windows NT systems, Windows 3.x and Windows 95 will work fine.You can find more info in Microsoft Knowledge base article Q172982.

0
 

Author Comment

by:RentRight
ID: 1463728
I am using windows 95, I checked the association by puting a shortcut on my desktop that was "http://www.rent-right.com"  This opens IE and dials in.

One other thing, I have two PC's at work.  One gives me an error (undefinded var.) for vbnullString, the other does not.  But both fail with a 2 from shellexecute.

Thanks for the help,
Rob
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:RentRight
ID: 1463729
Adjusted points to 120
0
 
LVL 1

Accepted Solution

by:
cip earned 120 total points
ID: 1463730
Rob,

VbNullString should give a "variable not defined" sintax error in vb3,
unless the "option explicit" statement is omitted in the declaration
section of the module.

The example below works fine on my PC, hope it can help since it is sligthly
different from yours. The second parameter in the ShellExecute declaration
is defined of type "Any" rather than "String", to allow passing a null pointer.
If you want to keep the "String" type, you should pass "open" as the second
parameter, for example:

ShellExecute(0&, "open", URL, "", "", 0)


--------------------------------------------
Declare Function ShellExecute Lib "shell.dll" (ByVal hwnd As Integer, ByVal lpOperation As Any, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer

Sub Command1_Click ()
    Dim r As Integer
    Dim URL As String

    URL = "http://www.rent-right.com"
    r = ShellExecute(0&, 0&, URL, "", "", 0)
   debug.print r
end sub
--------------------------------------------

0
 

Author Comment

by:RentRight
ID: 1463731
Thanks, you got it.

It was the way I was declaring ShellExecute.  I used the declare out of the book using the Windows API with VB.  When I changed it to your declare, all of my previous versions worked.

Thanks again.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

688 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