Solved

mystery

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

809 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