Solved

VB3: Access web site URL from program

Posted on 1998-06-18
6
474 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

828 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