Results 1 to 8 of 8

Thread: Commands By Keys

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    15

    Talking

    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

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    15

    but..

    is there a way it can just use the web browser i have built in?

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    15
    ok. does that work for vb 6? cuz thats what i'm using.

  6. #6
    Guest
    OF COURSE!!
    anything that works in VB5 should work in VB6.....

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    15

    Angry Well sorry but..

    It didn't work for me

  8. #8
    Guest
    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
  •  



Click Here to Expand Forum to Full Width