|
-
Jul 17th, 2000, 09:29 AM
#1
Thread Starter
New Member
how can i made a web browser with VB, and say when someone hits the A key, it goes to a certain website, and it they would hit the ARROW UP key, it would go to a different one, you know how? thx
-
Jul 17th, 2000, 09:37 AM
#2
Try this. It will open a different webiste when you press A or Arrow Up.
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
Dim URL As String
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If different Keys are pressed then set the URL to different websites
If KeyCode = vbKeyA Then URL = "www.vb-world.net"
If KeyCode = vbKeyUp Then URL = "www.hotmail.com"
If URL <> "" Then
'Open the website specified in URL
Retval = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", 1)
End If
End Sub
-
Jul 17th, 2000, 09:44 AM
#3
Thread Starter
New Member
but..
is there a way it can just use the web browser i have built in?
-
Jul 17th, 2000, 10:18 AM
#4
Frenzied Member
Sure!!! Just use
Code:
'Code earlier posted by MEGATRON
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If different Keys are pressed then set the URL to different websites
If KeyCode = vbKeyA Then URL = "www.vb-world.net"
If KeyCode = vbKeyUp Then URL = "www.hotmail.com"
If URL <> "" Then
'Open the website specified in URL in WebBrowser1
WebBrowser1.Navigate URL
End If
End Sub
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jul 17th, 2000, 10:31 AM
#5
Thread Starter
New Member
ok. does that work for vb 6? cuz thats what i'm using.
-
Jul 17th, 2000, 12:10 PM
#6
OF COURSE!!
anything that works in VB5 should work in VB6.....
-
Jul 17th, 2000, 01:18 PM
#7
Thread Starter
New Member
Well sorry but..
-
Jul 17th, 2000, 02:00 PM
#8
Make sure your code is in the Control that currently has the Focus. If you want the Form to recieve the keys first, then set the KeyPreview to True.
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
|