Please Help

Hello All

I am new to this group. Can anyone help me please.
I have one paragraph using that I have to key in
each character in my program. I want to compare
each and every character with the paragraph I have
already stored and if it doesnt matches the typing
should stop and there is a beep. Unless the user
inputs the right character it doesnt advances.

Please help me out.

Raman Narang
[email protected]

Comments

  • Put a textbox called Text1 in your form and ...
    [code]
    'general declration section
    Dim para
    Dim counter

    'initialise the variables
    Private Sub Form_Load()
    para = "this is the test para"
    counter = 0
    End Sub

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If counter < Len(para) Then
    counter = counter + 1
    If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    Beep
    KeyAscii = 0
    End If
    Else
    Beep
    KeyAscii = 0
    End If

    End Sub

    [/code]

    Feel free to tweak it.

    HTH
    [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]

  • Thanks a lot Flakes but there is one problem.
    if I am typing the right character it is alright
    but if i type wrong character it beeps ... ok..
    but doesnt allow me to type the right character or
    any other character.
    What I want is that if I type the wrong character
    system beeps and after that if I type the right
    character i am permitted to type it. Same way for
    whole of the para.
    And can u please also suggest that if I have to
    count how many words I have input in some specified
    time. Say the time limit is 10 mins.
    Thanks again.
    Raman

    : Put a textbox called Text1 in your form and ...
    : [code]
    : 'general declration section
    : Dim para
    : Dim counter
    :
    : 'initialise the variables
    : Private Sub Form_Load()
    : para = "this is the test para"
    : counter = 0
    : End Sub
    :
    : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : If counter < Len(para) Then
    : counter = counter + 1
    : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : Beep
    : KeyAscii = 0
    : End If
    : Else
    : Beep
    : KeyAscii = 0
    : End If
    :
    : End Sub
    :
    : [/code]
    :
    : Feel free to tweak it.
    :
    : HTH
    : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    :
    :

  • : Thanks a lot Flakes but there is one problem.
    : if I am typing the right character it is alright
    : but if i type wrong character it beeps ... ok..
    : but doesnt allow me to type the right character or
    : any other character.
    : What I want is that if I type the wrong character
    : system beeps and after that if I type the right
    : character i am permitted to type it. Same way for
    : whole of the para.
    : And can u please also suggest that if I have to
    : count how many words I have input in some specified
    : time. Say the time limit is 10 mins.
    : Thanks again.
    : Raman
    :
    : : Put a textbox called Text1 in your form and ...
    : : [code]
    : : 'general declration section
    : : Dim para
    : : Dim counter
    : :
    : : 'initialise the variables
    : : Private Sub Form_Load()
    : : para = "this is the test para"
    : : counter = 0
    : : End Sub
    : :
    : : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : : If counter < Len(para) Then
    : : counter = counter + 1
    : : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : : Beep
    : : KeyAscii = 0
    : : End If
    : : Else
    : : Beep
    : : KeyAscii = 0
    : : End If
    : :
    : : End Sub
    : :
    : : [/code]
    : :
    : : Feel free to tweak it.
    : :
    : : HTH
    : : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    : :
    : :
    :
    :


    In the code,the line
    [code]
    KeyAscii=0
    [/code]

    is the line which doesn't permit anything to be typed.

    Remove that and you will be allright.

    The other thing about counting words during a period requires a timer . I haven't used timers very much ,someone here will help you out on that.

    HTH
    [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]

  • : : Thanks a lot Flakes but there is one problem.
    : : if I am typing the right character it is alright
    : : but if i type wrong character it beeps ... ok..
    : : but doesnt allow me to type the right character or
    : : any other character.
    : : What I want is that if I type the wrong character
    : : system beeps and after that if I type the right
    : : character i am permitted to type it. Same way for
    : : whole of the para.
    : : And can u please also suggest that if I have to
    : : count how many words I have input in some specified
    : : time. Say the time limit is 10 mins.
    : : Thanks again.
    : : Raman
    : :
    : : : Put a textbox called Text1 in your form and ...
    : : : [code]
    : : : 'general declration section
    : : : Dim para
    : : : Dim counter
    : : :
    : : : 'initialise the variables
    : : : Private Sub Form_Load()
    : : : para = "this is the test para"
    : : : counter = 0
    : : : End Sub
    : : :
    : : : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : : : If counter < Len(para) Then
    : : : counter = counter + 1
    : : : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : : : Beep
    : : : KeyAscii = 0
    : : : End If
    : : : Else
    : : : Beep
    : : : KeyAscii = 0
    : : : End If
    : : :
    : : : End Sub
    : : :
    : : : [/code]
    : : :
    : : : Feel free to tweak it.
    : : :
    : : : HTH
    : : : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    : : :
    : : :
    : :
    : :
    :
    :
    : In the code,the line
    : [code]
    : KeyAscii=0
    : [/code]
    :
    : is the line which doesn't permit anything to be typed.
    :
    : Remove that and you will be allright.
    :
    : The other thing about counting words during a period requires a timer . I haven't used timers very much ,someone here will help you out on that.
    :
    : HTH
    : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    :
    :

    Yeah, I know timers like my both hands. And just before that, let's thanks Flakes for his help. And like he said, remove the line "KeyAscii = 0" but only the last one, okay? So, timers work like this.

    You must place a timer on your form and name it properly. Timers are hidden. I suggest a name like "TimerInput". Then, you must set the interval propertie. This propertie is in milliseconds (1000 ms = 1 sec). So I suggest you put 1000. Then you need a shared variable. Here is an example of a Timer routine.

    Write this in declarations:
    [code]
    Dim TimeTaken As Integer
    [/code]

    Then write this in your timer routine (TimerInput_Timer).
    [code]
    TimeTaken = TimeTaken + 1 'Add one second to your variable
    If TimeTaken = 60 * 10 Then
    '60 seconds * 10 minutes
    MsgBox "No more time!"
    End If
    [/code]

    This routine will work, but to count the number of words, you must tweak the code that Flakes gave you:

    [code]
    'general declration section
    Dim para
    Dim counter
    Dim TimeTaken 'this one should be already declared
    Dim Words 'This will count the number of words

    Private Sub Form_Load()
    para = "this is the test para"
    counter = 0
    End Sub

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If counter < Len(para) Then
    counter = counter + 1
    If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    Beep
    KeyAscii = 0
    If KeyAscii = 32 Then Words = Words + 1
    'This line will track the Space character, and every time it
    'is typed and correct, it will add 1 to Words value
    End If
    End If
    End Sub
    [/code]

    Francis Lacroix :
    System administrator
    SunSystems Labs
    http://sunsystemslabs.cjb.net

  • Thanks again Flakes and thanks to you too Francis
    my problem is still not solved. actually if I
    input the right character it is alright but if I
    input the wrong one then it stops and beeps but
    i am still not able to input the right character
    after that. The program should pause at the wrong
    character until the right character is input.

    Thanks for the timer too Francis. I will test it
    with the full paragraph which I have to input in
    the predefined time.

    Please help me out in my first problem which is
    to pause at the wrong input with beep and if right
    character is inputted then it should continue as it
    was.

    Thanks again

    Raman Narang

    : : : Thanks a lot Flakes but there is one problem.
    : : : if I am typing the right character it is alright
    : : : but if i type wrong character it beeps ... ok..
    : : : but doesnt allow me to type the right character or
    : : : any other character.
    : : : What I want is that if I type the wrong character
    : : : system beeps and after that if I type the right
    : : : character i am permitted to type it. Same way for
    : : : whole of the para.
    : : : And can u please also suggest that if I have to
    : : : count how many words I have input in some specified
    : : : time. Say the time limit is 10 mins.
    : : : Thanks again.
    : : : Raman
    : : :
    : : : : Put a textbox called Text1 in your form and ...
    : : : : [code]
    : : : : 'general declration section
    : : : : Dim para
    : : : : Dim counter
    : : : :
    : : : : 'initialise the variables
    : : : : Private Sub Form_Load()
    : : : : para = "this is the test para"
    : : : : counter = 0
    : : : : End Sub
    : : : :
    : : : : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : : : : If counter < Len(para) Then
    : : : : counter = counter + 1
    : : : : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : : : : Beep
    : : : : KeyAscii = 0
    : : : : End If
    : : : : Else
    : : : : Beep
    : : : : KeyAscii = 0
    : : : : End If
    : : : :
    : : : : End Sub
    : : : :
    : : : : [/code]
    : : : :
    : : : : Feel free to tweak it.
    : : : :
    : : : : HTH
    : : : : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    : : : :
    : : : :
    : : :
    : : :
    : :
    : :
    : : In the code,the line
    : : [code]
    : : KeyAscii=0
    : : [/code]
    : :
    : : is the line which doesn't permit anything to be typed.
    : :
    : : Remove that and you will be allright.
    : :
    : : The other thing about counting words during a period requires a timer . I haven't used timers very much ,someone here will help you out on that.
    : :
    : : HTH
    : : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    : :
    : :
    :
    : Yeah, I know timers like my both hands. And just before that, let's thanks Flakes for his help. And like he said, remove the line "KeyAscii = 0" but only the last one, okay? So, timers work like this.
    :
    : You must place a timer on your form and name it properly. Timers are hidden. I suggest a name like "TimerInput". Then, you must set the interval propertie. This propertie is in milliseconds (1000 ms = 1 sec). So I suggest you put 1000. Then you need a shared variable. Here is an example of a Timer routine.
    :
    : Write this in declarations:
    : [code]
    : Dim TimeTaken As Integer
    : [/code]
    :
    : Then write this in your timer routine (TimerInput_Timer).
    : [code]
    : TimeTaken = TimeTaken + 1 'Add one second to your variable
    : If TimeTaken = 60 * 10 Then
    : '60 seconds * 10 minutes
    : MsgBox "No more time!"
    : End If
    : [/code]
    :
    : This routine will work, but to count the number of words, you must tweak the code that Flakes gave you:
    :
    : [code]
    : 'general declration section
    : Dim para
    : Dim counter
    : Dim TimeTaken 'this one should be already declared
    : Dim Words 'This will count the number of words
    :
    : Private Sub Form_Load()
    : para = "this is the test para"
    : counter = 0
    : End Sub
    :
    : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : If counter < Len(para) Then
    : counter = counter + 1
    : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : Beep
    : KeyAscii = 0
    : If KeyAscii = 32 Then Words = Words + 1
    : 'This line will track the Space character, and every time it
    : 'is typed and correct, it will add 1 to Words value
    : End If
    : End If
    : End Sub
    : [/code]
    :
    : Francis Lacroix :
    : System administrator
    : SunSystems Labs
    : http://sunsystemslabs.cjb.net
    :
    :

  • Try this :
    [code]
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If counter < Len(para) Then
    counter = counter + 1
    If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    Beep
    counter = counter - 1
    End If
    Else
    Beep

    End If

    End Sub
    [/code]




    [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]

  • thanks a lot flakes this is working but
    only after I also include
    keyascii=0
    after the beep

    thanks a lot

    I really appreciate this effort.

    Raman Narang
    : Try this :
    : [code]
    : Private Sub Text1_KeyPress(KeyAscii As Integer)
    : If counter < Len(para) Then
    : counter = counter + 1
    : If Not Asc(Mid(para, counter, 1)) = KeyAscii Then
    : Beep
    : counter = counter - 1
    : End If
    : Else
    : Beep
    :
    : End If
    :
    : End Sub
    : [/code]
    :
    :
    :
    :
    : [size=4][b][blue]Fl[/blue][red]a[/red][blue]kes[/blue][/b][/size]
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories