|
-
Nov 23rd, 2000, 02:15 PM
#1
Thread Starter
Lively Member
Is there a way to Link a Command Button to a Web address?
So that when a usere clicks the button, it opens the default browser to a particular site?
Thank You
-
Nov 23rd, 2000, 02:22 PM
#2
_______
<?>
Code:
'open a browser and go to a www address
'bas module
'
Public 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 ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
Dim msg As String
msg = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
Dim msg1 As String
msg1 = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
Else
'It worked!
ShellToBrowser% = True
End If
End Function
'
'<<< event from application...click event of button >>>>>>>>
'
Private Sub cmdWeb_Click()
Dim Site As String
Dim success As Integer
Site = "http://www.Yahoo.com/" '& Trim(txtWeb.Text)
success% = ShellToBrowser(Me, Site, 0)
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 23rd, 2000, 04:03 PM
#3

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
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "http://www.vb-world.net", _
vbNullString, "c:\", SW_SHOWNORMAL
End Sub
-
Nov 23rd, 2000, 04:59 PM
#4
New Member
Public 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
ShellExecute me.hwnd, "Open", "http://www.search.msdn.com", "", "", 0
W2K/VB6/SQL2K
Feel the Source
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
|