Typing application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Screener
    New Member
    • Mar 2008
    • 7

    Typing application

    hi,

    I'm new to VB , and I've created a typing program that displays the character pressed and highlights it on the screen. The program displays the characters on a ReadOnly textbox. I could code all characters including the backspace and the enter. The only problem I'm facing right now is how to make the shift key display capital letters ?

    I tryed doing it the hard way with an if statement and then cases of all letters , yet it didn't word :(

    I know someone can help, and I hope they will

    thank you
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to handle the KeyDown event.

    Comment

    • Screener
      New Member
      • Mar 2008
      • 7

      #3
      that's what I did for all characters. I used the TextBox_KeyDown , how can I use it for the shift key?

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        In KeyUp or KeyDown, Check for "Shift"

        [code=vb]
        Private Sub Text1_KeyUp(Key Code As Integer, Shift As Integer)
        If Shift = 1 Then
        MsgBox "Shift Pressed.."
        End If
        End Sub
        [/code]

        Regards
        Veena

        Comment

        • Screener
          New Member
          • Mar 2008
          • 7

          #5
          thanks alot veena, but my problem is:

          when the user press the shift key, how can I make the next letter pressed capital ?

          I know when the user presses the shift key using this line of code

          Case e.keyCode = Keys.ShiftKey

          but how can I make it work, that's capilaizing the next letter ?!

          Comment

          • QVeen72
            Recognized Expert Top Contributor
            • Oct 2006
            • 1445

            #6
            Originally posted by Screener
            Case e.keyCode = Keys.ShiftKey
            but how can I make it work, that's capilaizing the next letter ?!
            Some thing Like this :

            UCase(Chr((e.Ke yCode)))

            REgards
            Veena

            Comment

            • Screener
              New Member
              • Mar 2008
              • 7

              #7
              how do I apply what you wrote on the next letter ?

              should I an if statement ?

              Comment

              • QVeen72
                Recognized Expert Top Contributor
                • Oct 2006
                • 1445

                #8
                Hi,

                Declare a Form Level Boolean Variable say, MyShift.
                In Key Up Check if Shift is pressed, Make

                [cODE=VBNET]
                If e.keyCode = Keys.ShiftKey Then
                MyShift = Not MyShift 'This Allows you to Toggle Upper and Lower Case
                End If
                [/code]

                And use an If Condition..
                If MyShift Then


                Regards
                Veena

                Comment

                • Screener
                  New Member
                  • Mar 2008
                  • 7

                  #9
                  Thank you so much Veena, that worked :)

                  Comment

                  • Screener
                    New Member
                    • Mar 2008
                    • 7

                    #10
                    there's also a minor problem with the Alt key

                    when the user presses alt, the corresponding button should be highlighted, but because I have a menu strip in my program, pressing the alt key causes the focus to be on the menu strip

                    Comment

                    • QVeen72
                      Recognized Expert Top Contributor
                      • Oct 2006
                      • 1445

                      #11
                      Hi,

                      Yes, that's a bit problem...
                      One work-around is :
                      While User Starts Typing, Disable or Hide the Menu.. and Show a Button with "Menu" as caption.
                      and Trap the "Alt" Key Pressed in Key Down event.
                      When the user is done typing, and if he wants the menu, then
                      in Button_Click event , Hide the button and Show the menu..
                      Little bit of coding is involved..

                      REgards
                      Veena

                      Comment

                      • Screener
                        New Member
                        • Mar 2008
                        • 7

                        #12
                        thanks alot you've been a great help

                        Comment

                        Working...