Solved

mystery

Posted on 2001-06-15
5
241 Views
Last Modified: 2013-11-13
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
Comment
Question by:kokZai
5 Comments
 
LVL 6

Expert Comment

by:JonFish85
ID: 6197588
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
 
LVL 5

Expert Comment

by:dgorin
ID: 6197597
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
 

Accepted Solution

by:
chvsuresh earned 20 total points
ID: 6197674
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
 

Expert Comment

by:mufaza2000
ID: 6198132
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
 

Author Comment

by:kokZai
ID: 6392596
Thank you guy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now