Solved

Typing error monitor

Posted on 2002-04-23
8
160 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

840 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