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.
Re: How to write sentences in Ascii code
Welcome to the forums.
Do you mean something like this?
VB Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 32) And (KeyAscii <= 126) Then
MsgBox Chr(72) & Chr(97) & Chr(99) & Chr(107)
End If
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.
Re: How to write sentences in Ascii code
You may generate a random number and set new keyascii:
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Randomize
If (KeyAscii >= 32) And (KeyAscii <= 126) Then
KeyAscii = Int((126 * Rnd) + 32)
End If
End Sub
Re: How to write sentences in Ascii code
Or better yet use all available characters:
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Randomize
KeyAscii = Int((255 * Rnd) + 1)
End Sub
Re: How to write sentences in Ascii code
... or just add or substract a value.
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 32) And (KeyAscii <= 126) Then
If KeyAscii > 80 Then
KeyAscii = KeyAscii - 5
Else
KeyAscii = KeyAscii + 5
End If
End If
End Sub
... or whatever...
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.
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?
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.
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.
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.