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. Make vbKeyReturn equivalent to vbKeyTab

Make vbKeyReturn equivalent to vbKeyTab

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 4 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.
  • N Offline
    N Offline
    nvmoss
    wrote on last edited by
    #1

    I have developed a data entry form and set the tab order, but in entering data, it seems more intuitive to use the Enter Key than the Tab to change the focus to the next text box. Is there a way to make these two keys work the same way in this application? Thanks! nvmoss

    J 1 Reply Last reply
    0
    • N nvmoss

      I have developed a data entry form and set the tab order, but in entering data, it seems more intuitive to use the Enter Key than the Tab to change the focus to the next text box. Is there a way to make these two keys work the same way in this application? Thanks! nvmoss

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

      you could trap for keycode of 13

      N 1 Reply Last reply
      0
      • J jimpar

        you could trap for keycode of 13

        N Offline
        N Offline
        nvmoss
        wrote on last edited by
        #3

        Thanks! I'm new at this. I assume that key code 13 is the Enter key, but how do I "trap" it? Thanks Again! nvmoss

        N C 2 Replies Last reply
        0
        • N nvmoss

          Thanks! I'm new at this. I assume that key code 13 is the Enter key, but how do I "trap" it? Thanks Again! nvmoss

          N Offline
          N Offline
          Nick Seng
          wrote on last edited by
          #4

          You "trap" it by adding this code in the KeyDown event

              If e.KeyCode = Keys.Enter Then
          
              End If
          

          HTH


          "if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone It's a weird Life

          1 Reply Last reply
          0
          • N nvmoss

            Thanks! I'm new at this. I assume that key code 13 is the Enter key, but how do I "trap" it? Thanks Again! nvmoss

            C Offline
            C Offline
            Charlie Williams
            wrote on last edited by
            #5

            I don't know why, but KeyPress tends to work better for this (for me, at least) than KeyDown.

            ' include whatever controls you want to have this functionality
            Private Sub KeyPressed(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles _
            TextBox1.KeyPress, TextBox2.KeyPress, TextBox3.KeyPress, TextBox4.KeyPress
            If e.KeyChar = ChrW(13) Then
            ProcessTabKey(True)
            e.Handled = True
            End If
            End Sub

            This isn't the only way to do what you want, but it works. Charlie if(!curlies){ return; }

            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