Results 1 to 5 of 5

Thread: Ascii only in text box

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Wink

    Ok, I want to type letters and numbers on the key board and
    have the ascii code come up in the text box, instead of text.
    This is as close as I can get:
    _______________________________________________
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Text1.Text = Text1.Text & KeyAscii
    End Sub
    ________________________________________________
    The "Text1.Text & KeyAscii" was just to get sequential characters in the text box.
    Notice that:
    mike becomes, ekim109105107101

    Three problems:
    1) If I type the word "mike", it comes out backwards(ascii included).
    2) I only want ascii not letters and not in reverse order.
    3) Things get worse when I try to use the "enter" key.

    If you create a simple textbox and cut and past the above code, you will see exactly what I mean.

    Thank's for any help!

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    haven't tried it but something like

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer) 
      Text1.Text = Text1.Text & cStr(KeyAscii)
      KeyAscii = 0
    End Sub
    Iain, thats with an i by the way!

  3. #3
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Try this;

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Text1.SelText = KeyAscii
    KeyAscii = 0
    End Sub

    You have to set KeyAscii to 0 to stop the actual letter you pressed appearing..

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Wink

    Thanks, that really helped.
    But what about using the Enter key to start on a new line (My text box is set for multiline).
    If Ascii (13) shows up thats OK, But I still would like to start a new line instead of miles of Ascii on a single line.

    Thank's

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    If KeyAscii = 13 then don't set it to zero.
    Iain, thats with an i by the way!

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