Results 1 to 10 of 10

Thread: How to write sentences in Ascii code

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    How to write sentences in Ascii code

    I recently got the idea to write a program that changes everything you type into something else. I tried writing it and it didn't work, but I know it can be done. If someone knows how to do this reply please...

    Here is my code

    Code:
    Private Sub Form_keypress(keyascii As Integer)
    If (keyascii >= 32) And (keyascii <= 126) Then
    keyascii = ' what i make it say
    End If
    End Sub
    I need to make it work.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to write sentences in Ascii code

    Welcome to the forums.

    Do you mean something like this?
    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2. If (KeyAscii >= 32) And (KeyAscii <= 126) Then
    3.     MsgBox Chr(72) & Chr(97) & Chr(99) & Chr(107)
    4. End If
    5. End Sub

    Edit If you are going to use the Form Keypress event as make sure you have the form's KeyPreview property set to true.
    Last edited by Hack; Mar 25th, 2005 at 01:44 PM.

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to write sentences in Ascii code

    You may generate a random number and set new keyascii:
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     Randomize
    3.     If (KeyAscii >= 32) And (KeyAscii <= 126) Then
    4.         KeyAscii = Int((126 * Rnd) + 32)
    5.     End If
    6. End Sub

  4. #4

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: How to write sentences in Ascii code

    ... or just add or substract a value.
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If (KeyAscii >= 32) And (KeyAscii <= 126) Then
    3.         If KeyAscii > 80 Then
    4.             KeyAscii = KeyAscii - 5
    5.         Else
    6.             KeyAscii = KeyAscii + 5
    7.         End If
    8.     End If
    9. End Sub
    ... or whatever...

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: How to write sentences in Ascii code

    Thanks for the help, but I am trying to write a program that changes everything you type (no matter where you type it) it comes out as something I make it say. I want it to do that + set the form to not be visible. But thanks again for the help.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to write sentences in Ascii code

    Quote Originally Posted by Sir Loin
    Thanks for the help, but I am trying to write a program that changes everything you type (no matter where you type it) it comes out as something I make it say. I want it to do that + set the form to not be visible. But thanks again for the help.
    This sounds a little suspect to me. For what purpose do you need to accomplish this goal?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: How to write sentences in Ascii code

    It does doesn't it...

    I just want to code a program like that to joke around with my friends and learn how to use KeyPress with sentences in ASCII code rather than one letter.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How to write sentences in Ascii code

    that is not a joke. do it in your program as a joke. they will know that you are responsible, and laugh if the want.

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to write sentences in Ascii code

    Quote Originally Posted by Sir Loin
    ... but I am trying to write a program that changes everything you type (no matter where you type it) it comes out as something I make it say. I want it to do that + set the form to not be visible. ...
    This also sounds like malicious to me ... Sorry.

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