|
-
Apr 10th, 2011, 10:05 PM
#1
Thread Starter
Junior Member
Open URL in the default web browser

I need help here. I'm making (something, I'm not going to tell you yet) and I have a Msgbox where if you click yes, I need it to open up the default web browser and to a specific web page. I need this answer in a few days. Any help will be appreciated and thanks in advance.
-
Apr 10th, 2011, 10:33 PM
#2
Re: Open URL in the default web browser
How about this.
vb 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 ' Open the default browser on a given URL ' Returns True if successful, False otherwise Public Function OpenBrowser(ByVal URL As String) As Boolean Dim res As Long ' it is mandatory that the URL is prefixed with http:// or https:// If InStr(1, URL, "http", vbTextCompare) <> 1 Then URL = "http://" & URL End If res = ShellExecute(0&, "open", URL, vbNullString, vbNullString, _ vbNormalFocus) OpenBrowser = (res > 32) End Function Private Sub Command1_Click() OpenBrowser ("www.vbforums.com") End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Apr 11th, 2011, 04:11 AM
#3
Addicted Member
Re: Open URL in the default web browser
I think, following is more faster & easy.
vb Code:
'Private Declaration for the whole project 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 'Code for object that is showing msgbox, like Command1_Click event Dim IntMsg As Integer IntMsg = MsgBox("Do you wants to go at VbForums.Com ? ? ?", vbYesNo) If IntMsg = vbYes Then retValue = ShellExecute(Form1.hwnd, "Open", "http://www.vbforums.com", 0&, 0&, 0&) End If
Last edited by Mehmood Iqbal; Apr 11th, 2011 at 04:27 AM.
Reason: Code Edited
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|