Results 1 to 9 of 9

Thread: Text Box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation

    How can I disable the "Enter" key in a
    multi-line text box?

    Thanks.
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 13 Then KeyCode = 0
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation Disable the "Enter" Key.

    The KeyDown event is not working with
    the "Enter" key!!!

    Any suggestions?

    Thanks



    [Edited by VBonliner on 10-16-2000 at 03:58 AM]
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation

    Problem with KeyDown event and the "Enter" Key.
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  5. #5
    Guest
    Use the KeyPress event.

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then KeyAscii = 0
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Thanks!

    Thanks Matthew. It worked.

    [Edited by VBonliner on 10-16-2000 at 08:25 AM]
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  7. #7
    Guest
    Likewise, Kedaman's method of using 13 (as opposed to vbKeyReturn) would work as well.

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    ...the difference being kedaman's code calls the default sound while Matthew's code doesn't.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9
    Guest
    The code that kedaman gave for KeyCode did not seem to work.

    But 13 and vbKeyReturn are the same thing.

    So this:

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then KeyAscii = 0
    End Sub
    would be the same as this:

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then KeyAscii = 0
    End Sub
    But it does not work in the KeyCode event.
    Just a little mistake by kedaman, we aren't all perfect . I make mistakes all the time, do I care? A little, but oh well, this is vb-world, a little edit/delete post can change everything .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width