[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

How to Program command button to launch web browser

I am trying to setup a simple self executable that has a splash screen and then goes to a screen where you click on a command button and it lauches your internet browser and takes you to the specified web page I have visual basic version 5.0 learning edition and I see nothing in any of my books on how to do this I do not want anything except for a command button and a label on the form (no menu's etc...)
please help i need to create this a.s.a.p.
0
briancassin
Asked:
briancassin
  • 5
  • 3
  • 3
  • +1
1 Solution
 
mark2150Commented:
In the buttons CLICK event you place your code to launch the browser. You can use SHELL to launch an application.

Private Sub Cmd_Click()
  Shell("IEXPLORE.EXE http://mysite.com"), 1
End Sub

This is close off the top of my head.

M
0
 
mcriderCommented:
Actually, you want to do:

Shell("start http://www.yourwebpage.com"),1

Don't call iexplorer directly, because it may not be in the search path, and IE may not even be installed on the computer...  May be Netscape...


Cheers!
0
 
VbmasterCommented:
Here's another method available, which will give you the error message if any..


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

Function Run(strFilePath As String, Optional strParms As String, Optional strDir As String) As String
       
  Const SW_SHOW = 5
 
  'Run the Program and Evaluate errors
  Select Case ShellExecute(0, "Open", strFilePath, strParms, strDir, SW_SHOW)
  Case 0
    Run = "Insufficent system memory or corrupt program file"
  Case 2
    Run = "File not found"
  Case 3
    Run = "Invalid path"
  Case 5
    Run = "Sharing or Protection Error"
  Case 6
    Run = "Seperate data segments are required for each task"
  Case 8
    Run = "Insufficient memory to run the program"
  Case 10
    Run = "Incorrect Windows version"
  Case 11
    Run = "Invalid program file"
  Case 12
    Run = "Program file requires a different operating system"
  Case 13
    Run = "Program requires MS-DOS 4.0"
  Case 14
    Run = "Unknown program file type"
  Case 15
    Run = "Windows program does not support protected memory mode"
  Case 16
    Run = "Invalid use of data segments when loading a second instance of a program"
  Case 19
    Run = "Attempt to run a compressed program file"
  Case 20
    Run = "Invalid dynamic link library"
  Case 21
    Run = "Program requires Windows 32-bit extensions"
  Case Else
    Run = ""
  End Select

End Function

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
briancassinAuthor Commented:
Is this the complete code for the button to access the website and it can be made a self executable correct so I can distribute onto diskettes ?

here is what you wrote I am assuming this is the complete code for the command button


Shell("start http://www.yourwebpage.com"),1


so here is hwo the completed code would look and this is all I need correct ?

Private Sub Cmd_Click()
  Shell("start http://www.yourwebpage.com"),1
End Sub



0
 
mark2150Commented:
Yep. It's that easy!

M
0
 
VbmasterCommented:
Actually it's ought to be

  Private Sub Cmd_Click()
    Call Shell("start http://www.yourwebpage.com", 1)
  End Sub
0
 
mcriderCommented:
Yes, That's it!


Cheers!
0
 
briancassinAuthor Commented:
It worked but now I am having a problem when I make it a self executable that the form is truncated but it looks fine on my system
0
 
mcriderCommented:
What do you mean by truncated?
0
 
briancassinAuthor Commented:
The actual form looks fine with my computer but when it is installed on others pc's the actual form size is smaller and the graphic is got part of it cut off..... almost like it got squashed but the text does not appear to be squashed the best way to describe it is that it is cut off
0
 
mcriderCommented:
Sounds like what you're dealing with now is a Screen Resolution/Font Size problem...

There are 2 windows setting (Large Font and Small Font) You can get to these settings by right-clicking on the desktop and selecting "Properties"... Then take a look at the "Settings" tab.

I would suggest testing your program with both fonts and different screen resolutions (the "Display Area" of the same settings tab.


Cheers!
0
 
VbmasterCommented:
Let's see.. can it be because the other pc's don't have the same screen resolution?
 
0
 
mcriderCommented:
Vbmaster,

That's the whole point of testing with different Screen Resolution/Font Sizes...

;-)
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 5
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now