Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Get enter button command

Get enter button command

Scheduled Pinned Locked Moved Visual Basic
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harveyhanson
    wrote on last edited by
    #1

    VB.NET 2005: I want a user to type their nam, then make it so my program recognises when the user presses the enter key (or they can click on the button), then acts as tho a button has been pressed, how would i do this, is it a press down event?

    J 1 Reply Last reply
    0
    • H harveyhanson

      VB.NET 2005: I want a user to type their nam, then make it so my program recognises when the user presses the enter key (or they can click on the button), then acts as tho a button has been pressed, how would i do this, is it a press down event?

      J Offline
      J Offline
      JUNEYT
      wrote on last edited by
      #2

      Well it is not complicated. You define the procedure as a sub or function what has to be handled when user pushes the enter key. Check this code please. :wtf:

      ' Handle the KeyDown event to determine the type of character entered into the control.
      Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
               Handles textBox1.KeyDown
            
              ' Determine whether the keystroke is a number from the top of the keyboard.
              If e.KeyCode = 13 Then
                 Call DoMyTask() ' That must be your procedure or function
              End If
          End Sub 
      

      What a curious mind needs to discover knowledge is noting else than a pin-hole.

      H 1 Reply Last reply
      0
      • J JUNEYT

        Well it is not complicated. You define the procedure as a sub or function what has to be handled when user pushes the enter key. Check this code please. :wtf:

        ' Handle the KeyDown event to determine the type of character entered into the control.
        Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
                 Handles textBox1.KeyDown
              
                ' Determine whether the keystroke is a number from the top of the keyboard.
                If e.KeyCode = 13 Then
                   Call DoMyTask() ' That must be your procedure or function
                End If
            End Sub 
        

        What a curious mind needs to discover knowledge is noting else than a pin-hole.

        H Offline
        H Offline
        harveyhanson
        wrote on last edited by
        #3

        How do i referance to something like a btn1_Click command?

        M 1 Reply Last reply
        0
        • H harveyhanson

          How do i referance to something like a btn1_Click command?

          M Offline
          M Offline
          M Hall
          wrote on last edited by
          #4

          Make sure you have a button click event attach to your button then use code some what like this to actuate it. YourButton_Click(YourButton, New EventArgs)

          H 1 Reply Last reply
          0
          • M M Hall

            Make sure you have a button click event attach to your button then use code some what like this to actuate it. YourButton_Click(YourButton, New EventArgs)

            H Offline
            H Offline
            harveyhanson
            wrote on last edited by
            #5

            Sorted, cheers for your help :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups