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
Printable View
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
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
is there a way it can just use the web browser i have built in?
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
ok. does that work for vb 6? cuz thats what i'm using.
OF COURSE!!
anything that works in VB5 should work in VB6.....
It didn't work for me
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.