• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

mystery

hi..i need to understand this program below. Let me explain what happened once i run this program. Whatever i key it will appear "Hi! how are you vijay?" . The more i type the more it will appear.

i need to understand how does this program. The code below does not show this sentence hi! how are you vijay?". Where does this code store?????

How can i modify the sentence instead of h, how are you vijay?



Dim i(24)
Dim j As Integer
Dim msg As String

Private Sub Form_Initialize()
Form1.BorderStyle = 0
End Sub

Private Sub Form_Load()
Name1 = InputBox("What is your sweet name?")
j = 0
i(0) = 72
i(1) = 105
i(2) = 44
i(3) = 32
i(4) = 104
i(5) = 111
i(6) = 119
i(7) = 32
i(8) = 114
i(9) = 32
i(10) = 117
i(11) = 63
i(12) = 32
i(13) = 32
i(14) = 45
i(15) = 32
i(16) = 32
i(17) = 86
i(18) = 105
i(19) = 106
i(20) = 97
i(21) = 121
i(22) = 46
i(23) = 32
i(24) = 32

End Sub

Private Sub Form_Unload(Cancel As Integer)
If (MsgBox("Do you enjoy tying dear? ", vbYesNo, Name1)) = vbYes Then
 MsgBox "Take Care bye"
 Else
For c = 1 To 100
 MsgBox " I am sorry", , Name1
 If c = 99 Then
 c = 0
 End If
 Next c
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> i(j) Then
KeyAscii = i(j)
End If
If j = 24 Then
j = 0
Else
j = j + 1
End If
End Sub
0
kokZai
Asked:
kokZai
1 Solution
 
JonFish85Commented:
only thing I can think of is running with a full compile (Ctrl + F5 when in VB). Other than that Im stuck! oh, btw is that the FULL code for ur project?
0
 
dgorinCommented:
Each of the i(xx) is an ascii code.  Look closely at the code in the keypress, you'll see that if the keycode you pressed isn't the next code in the array, what you pressed is replaced by the array code.  That's where your sentence comes from.  You can find the character codes in the VB documentation.
0
 
chvsureshCommented:
Hey just comment the code in the keypress event of text box. Then u can type what ever u want in the text box.

Reason: The characters you have typed will be checked up with the characters in the array (number wise ie the first character typed in the text box is checked with the first element in the array and the second character typed is checked with the second element in the array and so until 24 characters. Once u enter 25th character its again checked with 1st element in the array and so on. so if the ascii value of the character you have typed doesnt match with the value in the array, then the ascii value in the array is taken. so every time u press a character, u get the character which is stored in the array (if both the ascii values doesnt match up).

rgds
suresh
0
 
mufaza2000Commented:
Yes it pretty easy.  The Keying Event you are using (KeyPress) by Setting KeyAscii it Overwrites what was Entered by the Keyboard.  Check the MSDN Help files you can even cancel the Key Pressed.
0
 
kokZaiAuthor Commented:
Thank you guy
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now