Solved

VB3: Access web site URL from program

Posted on 1998-06-18
6
470 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
Comment Utility
Check if you have assosiation for .html files
0
 
LVL 1

Expert Comment

by:cip
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:RentRight
Comment Utility
Adjusted points to 120
0
 
LVL 1

Accepted Solution

by:
cip earned 120 total points
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now