Solved

mystery

Posted on 2001-06-15
5
240 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

12 Experts available now in Live!

Get 1:1 Help Now