Solved

Typing error monitor

Posted on 2002-04-23
8
158 Views
Last Modified: 2010-05-02
G'day,
The basics:
I want to spell out a string (say "myword") with
for t = 1 to Len(myword)
 Letter = mid(myword,t,1)

I now want to compare this Letter with a character typed in a TextBox and if correct move on to character 2 and so on and type the whole word.
How can I do this please?
Thank you,   Dan
0
Comment
Question by:dierdan
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6964821
Try this,

I just developed for you, it is working for me. If it does not work for you, tell me i will mail you the project.

My email id is n_narayanan@yahoo.com

Option Explicit
Dim OrigMsg As String
Dim cnt As Integer
Private Sub Form_Load()
cnt = 1
OrigMsg = "myword"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then 'backspace
    cnt = cnt - 1
    If cnt < 0 Then
        cnt = 1
    End If
    Exit Sub
End If

If Mid(OrigMsg, cnt, 1) = Chr(KeyAscii) Then
cnt = cnt + 1
    Exit Sub
Else
    KeyAscii = 0
    Exit Sub
End If

End Sub


Cheers

Narayanan
0
 
LVL 1

Accepted Solution

by:
hiranmaya earned 100 total points
ID: 6964853
Hi,

Try like following...


Dim strtocompare As String

Private Sub Form_Load()
strtocompare = "myword"
End Sub

Private Sub Text1_Change()
'check each character
If StrComp(Text1.Text, Mid(strtocompare, 1, Len(Text1.Text))) = 0 Then
    Debug.Print "right"
Else
    Debug.Print "wrong"
    'replace previous characters if any
    If Len(Text1.Text) = 1 Then
        Text1.Text = ""
    ElseIf Len(Text1.Text) > 1 Then
        Text1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)
    End If
End If
End Sub
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6966283
hiranmaya ->  Please use comments as the other experts before you have done here.  The person asking the question can always convert the first best response comment to the accepted answer to grade and close it.  By Proposing an Answer as you have done here, it moved this question from the Open Question queue to the Locked Question queue, and few additional experts will step in to help; so a disservice to the Asker who seeks expeditious solutions and seeks more than one possibility.

More about that here:
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

dierdan -->  If the proposed answer serves you, please accept it to grade and close this.  If it does not, please reject it and add comments.

Thank you,
Moondancer - EE Moderator
0
 

Author Comment

by:dierdan
ID: 6970609
Hi,
Both hiranmaya and narayanan have solved my question.
I am inclined to favour narayanan's answer but have no reason to reject hiranmaya's and therefore accept it.
I am posing a more general question related to this question.
Thank you both hiranmaya and narayanan for your input
Dan
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Expert Comment

by:n_narayanan
ID: 6970751
Dierdan

Thanks.

Congratulations hiranmaya.

But I have responded before hiranmaya's solution.

Narayanan.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6971511
I have posted a question for you, Narayanan, without charging the Dierdan for it in the question below for your help here.  Dierdan, please let us know if/when such situations occur so we can process point splits for you, by posting a zero point question in Community Support, include the link.

Thanks,

 Points for n_narayanan ->  Please comment here
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20294017

Moondancer - EE Moderator
0
 

Author Comment

by:dierdan
ID: 6972789
You are right moondancer, under the circumstances I should have split the points.
I wish to make amends by granting Naraynan 100 points also.
Thanks Narayanan.
Cheers,      Dan
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6974960
Thank you, Dan.  I have already done this.
Moondancer - EE Moderator
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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

18 Experts available now in Live!

Get 1:1 Help Now