Change Case

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moamin123
    New Member
    • Nov 2007
    • 14

    Change Case

    I have created a keyboard program i am using a textbox as the output and buttons for the input. is there anyone who knows hw i could use the caps lock feature

    i am currently tryin 2 use a check box however the problem arises after i uncheck the box because if i pres another button the letters still apear in CAPITALS
  • YarrOfDoom
    Recognized Expert Top Contributor
    • Aug 2007
    • 1243

    #2
    can you give the piece of code that handles the capitals?
    it would help very much

    Comment

    • moamin123
      New Member
      • Nov 2007
      • 14

      #3
      Well so far I have come up with this code:
      but again when I unchek the chekbox everything in the text box turns to lowercase:


      [CODE=vbnet]Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged
      If Me.CheckBox1.Ch ecked = True Then
      Me.TextBox1.Cha racterCasing = CharacterCasing .Normal
      End If
      If Me.CheckBox1.Ch ecked = False Then
      Me.TextBox1.Cha racterCasing = CharacterCasing .Lower
      End If
      End Sub[/CODE]
      Last edited by Killer42; Nov 6 '07, 11:58 PM. Reason: Added CODE-vbnet tag

      Comment

      • YarrOfDoom
        Recognized Expert Top Contributor
        • Aug 2007
        • 1243

        #4
        If your trying to simulate a caps-button, I would use something like this:

        [code=vb]Private Sub button_a() Handles button_a.Click
        if checkbox1.check ed = true then
        textbox1.text = textbox1.text & "A"
        else
        textbox1.text = textbox1.text & "a"
        end if
        end sub[/code]
        This for all of your buttons.

        Yarr
        hint: use code-tags, it helps people reading your code

        Comment

        • kadghar
          Recognized Expert Top Contributor
          • Apr 2007
          • 1302

          #5
          Originally posted by yarrofdoom
          If your trying to simulate a caps-button, I would use something like this:

          [code=vb]Private Sub button_a() Handles button_a.Click
          if checkbox1.check ed = true then
          textbox1.text = textbox1.text & "A"
          else
          textbox1.text = textbox1.text & "a"
          end if
          end sub[/code]
          This for all of your buttons.

          Yarr
          hint: use code-tags, it helps people reading your code
          in this case, wouldnt it be easier to write in the keypress event something like

          if checkbox1.check ed = true then keyascii = asc(ucase(chr(k eyascii)))

          Instead of writing a case for each key

          HTH

          Comment

          • YarrOfDoom
            Recognized Expert Top Contributor
            • Aug 2007
            • 1243

            #6
            Originally posted by kadghar
            in this case, wouldnt it be easier to write in the keypress event something like

            if checkbox1.check ed = true then keyascii = asc(ucase(chr(k eyascii)))

            Instead of writing a case for each key

            HTH
            I don't think it's usefull in this case, because he is using buttons on a form for the typing, he's create something like "on-screen keyboard"

            Comment

            • kadghar
              Recognized Expert Top Contributor
              • Apr 2007
              • 1302

              #7
              Ô_o wait a sec

              was it checkbox1.check ed or checkbox1.value ??

              Well if you have troubles with one of them, try the other.

              Comment

              • YarrOfDoom
                Recognized Expert Top Contributor
                • Aug 2007
                • 1243

                #8
                Originally posted by moamin123
                Well so far i have come up with this code:
                but again when i unchek the chekbox everything in the text box turns to lowercase


                [code=vb]Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged
                If Me.CheckBox1.Ch ecked = True Then
                Me.TextBox1.Cha racterCasing = CharacterCasing .Normal
                End If
                If Me.CheckBox1.Ch ecked = False Then
                Me.TextBox1.Cha racterCasing = CharacterCasing .Lower
                End If[/code]
                End Sub
                Actually, there's nothing wrong with this code, but it's the logic behind it that is wrong.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Originally posted by yarrofdoom
                  Actually, there's nothing wrong with this code, but it's the logic behind it that is wrong.
                  Yes, this code says to convert whatever is currently in the textbox to upper or lower case. What you actually need to do is check the current setting of the checkbox before adding each character.

                  Comment

                  • kadghar
                    Recognized Expert Top Contributor
                    • Apr 2007
                    • 1302

                    #10
                    Originally posted by yarrofdoom
                    I don't think it's usefull in this case, because he is using buttons on a form for the typing, he's create something like "on-screen keyboard"
                    i see, but it depends on how he is doing it. anyway, it can be written in the keypress event of the form.

                    or when the checkbox is checked, in the keydown event of the form, if the keycode is between 65 and 90, then it puts chr(keycode) in the textbox.

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by kadghar
                      i see, but it depends on how he is doing it. anyway, it can be written in the keypress event of the form...
                      I think the point yarr was making is that no keyboard events will be happening, since the user is just clicking the mouse.

                      Comment

                      • kadghar
                        Recognized Expert Top Contributor
                        • Apr 2007
                        • 1302

                        #12
                        Originally posted by Killer42
                        I think the point yarr was making is that no keyboard events will be happening, since the user is just clicking the mouse.
                        oh, i see... sorry, hadnt understand.

                        Comment

                        Working...