Results 1 to 13 of 13

Thread: Giving Button Functions?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Giving Button Functions?

    I don't know if this is the convenient spot to post this thread, but I wonder if anyone can help me on my browser?

    I am very new to this, and would like some basic help on how to give my buttons some functions. For example, I want the 'back' button for my browser to go back a page, which is ALT + LEFT. How do I assign "alt + left" for the back button?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Giving Button Functions?

    this should do it

    vb Code:
    1. SendKeys.Send("%{LEFT}")

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    Like I said, big big beginner

    where do I apply that coding, on that button right

    and its ALT + left so.. let me try.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    okay i got this error "Specified repeat count is not valid."

    i think it kept clicking it infinity? how can you do it so when you click it does it once

    -sry for doublepost

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Giving Button Functions?

    just put it in your button_click event. doubleclick the button + vb will open the button_click event in your code window

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Giving Button Functions?

    SendKeys.Send("%{LEFT}") specifies to send alt+left to the application with the focus (i.e. your application)

  7. #7
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Giving Button Functions?

    While SendKeys is the way to simulate a certain key combination to your program, I don't think it's the best way here...

    I suppose 'my browser' means that you got a webbrowser control on your form? If so, you can simply call it's "GoBack" function. There is no need to use SendKeys in this case.

    If you don't have your own browser control but you mean an external browser (internet explorer, whatever) then maybe SendKeys is the way to do this...

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    ok heres what my code lines look like for the button:
    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            SendKeys.Send("%{LEFT}")
        End Sub
    End Class
    when i push f5 to test it, i click the button and nothing happens
    shudnt the button be affiliated with the webbrowser?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    YES a webmaster is what i mean. where is this goback funtion found?

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Giving Button Functions?

    if sendkeys doesn't work, try NickThissens solution

  11. #11

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    it works!

    THANK YOU EVERYBODY FOR YOUR TIME AND SUPPORT!

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    22

    Re: Giving Button Functions?

    hmm i come with another problem....

    Code:
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Me.WebBrowser1.Stop()
        End Sub
    that doesnt seem to work...

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