how can i know the keyAscii vlaue of "delete" key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghunadhs
    New Member
    • May 2007
    • 52

    how can i know the keyAscii vlaue of "delete" key

    with help of key press evnt i am able to find the KeyAscii values.. but i am unable to find the ascii values of "delete","home" ,"pageUp", ...etc..

    In my application there is a need to find whether user pressed "delete" key or not.

    if u know how to do this.. pls let me know it..

    Thanks in advance:
    regards:
    raghunadhs
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Generally speaking, an easy way to find out these things is to run a test program, do the action yourself (press Delete, or whatever) and test the result. For example, put code in the KeyPress event to print KeyAscii to the immediate window.

    However, I suspect that these particular keys may not make it to the KeyPress event. You may need to trap them in KeyDown, which occurs first. Note, if you want to be able to test these things for the entire form before they reach the individual controls, set the form's KeyPreview property to True.

    Comment

    • kadghar
      Recognized Expert Top Contributor
      • Apr 2007
      • 1302

      #3
      It's 8

      and as killer said, many of those cannot be used in the KeyPress, but you can use Delete in KeyDown, so dim a boolean and you're done

      [CODE=vb]option explicit
      dim boo1 as boolean

      sub text1_keydown(k eycode as integer...)

      if keycode = 8 then boo1 = true

      end sub[/CODE]

      hope that helps

      Comment

      • cutequencher
        New Member
        • Jun 2007
        • 4

        #4
        another thing is to use the keys property...
        example:
        keys.delete

        i have a code here, maybe it could help you...
        Protected Overrides Function ProcessDialogKe y(ByVal keyData As System.Windows. Forms.Keys) As Boolean
        Dim pt As Point
        Dim hti As DataGrid.HitTes tInfo

        pt = Me.PointToClien t(Cursor.Positi on)
        hti = Me.HitTest(pt)

        If keyData = Keys.Delete Then

        If hti.Type = Me.HitTestType. RowHeader Then
        If MessageBox.Show ("Delete this row?", "Confirm Delete", _
        MessageBoxButto ns.YesNo) = DialogResult.No Then
        Return True
        Else
        RaiseEvent DeletedRow(Me, New EventArgs)
        End If
        End If
        End If

        End Function

        i am using it for the verification if the user is about to delete a data...
        keys properties will provide you everything you need..

        Comment

        • shaileshb
          New Member
          • Jun 2007
          • 27

          #5
          hi all,

          ln the above to post, they mentioned that u have to use keydown or keyup event this is correct
          if u want to find out ascii values for alphabets like "A to Z" or "a to z" then u should go for keypress event else u can go for keydown or keyup event
          ex.


          'if u want to go for delete, pgup, pgdown, F1, F2...etc

          Sub Text1_KeyDown(K eyCode As Integer, Shift As Integer)
          msgbox keycode
          End sub

          'if u wnat to find ascii values for "A to Z" etc.

          Sub Text1_KeyPress( KeyAscii As Integer)
          msgbox KeyAscii
          End Sub

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by cutequencher
            another thing is to use the keys property...
            example:
            keys.delete
            ...
            That depends on the VB version. I don't think we've established what version is in use, yet. But I don't think VB6 has this.

            Comment

            • hariharanmca
              Top Contributor
              • Dec 2006
              • 1977

              #7
              Originally posted by Killer42
              That depends on the VB version. I don't think we've established what version is in use, yet. But I don't think VB6 has this.
              Yha, But we can use KEYDOWN or KEYUP Events there


              Code:
              Private Sub ControlName_KeyDown(KeyCode as Integer, Shift as Integer)
                       if KeyCode = vbKeyDelete then
                              do true stmt....
                       else
                              do False stmt....
                      endif
              End Sub

              i think this will help u.

              (I don't have VB in my system so not tested)

              Comment

              • raghunadhs
                New Member
                • May 2007
                • 52

                #8
                Thanks all,
                I got it, through u r suggestions. Thank u very much.
                regards:
                raghunadhs

                Comment

                Working...