Results 1 to 2 of 2

Thread: Need some help here~~

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    34

    Need some help here~~

    I'm using vb and I did a little test on the key press time (the time we press down a key until we release it). i did this, it works.

    Code:
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    
            'Start the first stopWatch.
            sw1.Start()
    
    End Sub
    
        Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
    
            'Turn off the first stopWatch.
            sw1.Stop()
    
            sec = sw1.ElapsedMilliseconds
               
       End Sub
    Next, i tried to count the time gap between 2 key press.
    Something like : Key up, stopwatch start. Next keydown, stopwatch stop.
    i found out that the system can't make it start from keyup then go to keydown.

    i tried this but it didn't work.


    Code:
    dim counter_one as integer=0
    dim counter_two as integer=0
    
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    
    
            counter_two +=1
    
           if counter_two>=2 then
    
           sw1.stop()
    
            sec = sw1.ElapsedMilliseconds
    
            end if
            
    
        End Sub
    
    
    
        Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
    
    counter_one +=1
    
    if counter_one>=1 then
    sw1.start()
    end if
    
            
    
       End Sub
    Anyone has idea how to do it?

    Thanks!!

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Need some help here~~

    Hi Rachel,

    You really need this one in the VB.Net forum so more people can see this and help you.

    What is your end goal with this, what are you trying to accomplish with your program here please?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width