Solved

Typing error monitor

Posted on 2002-04-23
8
159 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

816 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