Results 1 to 15 of 15

Thread: timer and capture the letter [RESOLVED]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    timer and capture the letter [RESOLVED]

    hi all
    i need help regarding the timer and capture the letter and display it.how do i blink the letter for like 5sec and go to the next letter and if needed capture it on to the label.
    example :
    the letter "A" blink for 5 sec then "B" start to blink if the letter is needed it will be capture on to the label.

    VB Code:
    1. Private Sub Form_Load()
    2.    ' Start the timer.
    3.    Timer1.Interval = 500
    4.    Timer1.Enabled = True
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8. dim i as integer
    9.  
    10. For i = 0 To 0
    11. ' Toggle the color of the letter "A"
    12.     If Label1.ForeColor = vbRed Then
    13.         Label1.ForeColor = vbBlack
    14.     Else
    15.        Label1.ForeColor = vbRed
    16.     End If
    17.  Next i
    18. End Sub
    Attached Images Attached Images  
    Last edited by surface; Jun 30th, 2005 at 03:06 AM.

  2. #2
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    hmmm.. going to lunch now. if nobody answers in one hour, I'll post it.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  3. #3
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: timer and capture the letter

    VB Code:
    1. dim a as integer
    2.  
    3. Private Sub Form_Load()
    4. a = 0
    5.    Timer1.Interval = 500
    6.    Timer1.Enabled = True
    7. End Sub
    8.  
    9. Private Sub Timer1_Timer()
    10. a = a + 1
    11.     If Labela.ForeColor = vbRed Then
    12.         Labela.ForeColor = vbBlack
    13.     Else
    14.        Labela.ForeColor = vbRed
    15.     End If

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    k thx i try on it
    Last edited by surface; Jun 29th, 2005 at 11:45 PM.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    i manage to make the blinking part but how do i capture the letter and display it in the label?
    Attached Files Attached Files

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    i put this in the command box but it overwrite to the next letter how do i solve it, i need make it to a sentance and how do i solve the "space" to leave a spacing "backspace" to go back 1 spacing and "Clear" to clear away all the words in the label.sorry for the trouble

    VB Code:
    1. Private Sub Command1_Click()
    2. Label27 = Label1(i).Caption
    3. End Sub

    my program code:
    VB Code:
    1. Dim i As Integer
    2. Dim time As Double
    3. Option Explicit
    4.  
    5. Private Sub Command1_Click()
    6. Label27 = Label1(i).Caption
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. Timer1.Interval = 500
    11. Timer1.Enabled = True
    12. End Sub
    13.  
    14. Private Sub Timer1_Timer()
    15. If i >= Label1.Count Then i = 0
    16. If Label1(i).ForeColor = vbRed Then
    17.     Label1(i).ForeColor = vbBlack
    18. Else
    19.     Label1(i).ForeColor = vbRed
    20. End If
    21. time = time + 0.5
    22. If time >= 5 Then
    23.     time = 0
    24.     i = i + 1
    25. End If
    26. End Sub

  7. #7
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    okay. sorry. i took a long lunch.

    I downloaded your code. have no idea what you hope to accomplish with this form, but here is what your're missing:

    Private Sub Label1_Click(Index As Integer)
    If Index < 25 Then Label27 = Label27 & Chr$(Index + 65)
    If Index = 25 Then Label27 = ""
    If Index = 26 Then Label27 = Label27 & " "
    If Index = 27 And Len(Label27) > 0 Then Label27 = Left$(Label27, Len(Label27) - 1)
    End Sub

    Add this sub to what you already had in the project you uploaded and it should work fine
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  8. #8
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    by the way, if you're just starting out in VB, now is the perfect time to stop and switch to .Net (before you learn a lot of things you'll have to unlearn)
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    the code is for mouse when u click the letter would appear but i need the letter blink and use the command button to capture it to make it a sentence. cuz i will be using a push button switch using microcontroller to get the letter using the command button.sorry for the trouble

    VB Code:
    1. Private Sub Label1_Click(Index As Integer)
    2. If Index < 25 Then Label27 = Label27 & Chr$(Index + 65)
    3. If Index = 25 Then Label27 = ""
    4. If Index = 26 Then Label27 = Label27 & " "
    5. If Index = 27 And Len(Label27) > 0 Then Label27 = Left$(Label27, Len(Label27) - 1)
    6. End Sub

  10. #10
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    OKAY. I think I have the idea. kind of a PacMan hi - score type concept. the letters flash until you click one then that one flashes for 5 secs and goes to next one unless you click one too. Why can't you use my way and directly click them into the box?

    Doesn't matter. very easy.
    forget everything else

    below is the code for the whole form:
    VB Code:
    1. Dim i As Integer
    2. Dim time As Double
    3. Option Explicit
    4.  
    5. Private Sub Command1_Click()
    6. ShowLetter (i)
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. Timer1.Interval = 500
    11. Timer1.Enabled = True
    12. End Sub
    13.  
    14. Private Sub Timer1_Timer()
    15. If i >= Label1.Count Then i = 0
    16. Dim t As Integer
    17. For t = 0 To 27
    18. If t <> i Then Label1(t).ForeColor = vbBlack
    19. Next t
    20. If Label1(i).ForeColor = vbRed Then
    21.     Label1(i).ForeColor = vbBlack
    22. Else
    23.     Label1(i).ForeColor = vbRed
    24. End If
    25. time = time + 0.5
    26. If time >= 5 Then
    27.     time = 0
    28.     i = i + 1
    29. End If
    30. End Sub
    31. Private Sub Label1_Click(Index As Integer)
    32. i = Index
    33. End Sub
    34. Private Sub ShowLetter(Index)
    35. If Index < 25 Then Label27 = Label27 & Chr$(Index + 65)
    36. If Index = 25 Then Label27 = ""
    37. If Index = 26 Then Label27 = Label27 & " "
    38. If Index = 27 And Len(Label27) > 0 Then Label27 = Left$(Label27, Len(Label27) - 1)
    39. End Sub
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  11. #11

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    yup that is what i need really thx alot for all the help

  12. #12
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    no problem . slow day at the office
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  13. #13

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    i in my school doing the project slow day for me too 2 more hour to go

  14. #14
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: timer and capture the letter

    oh? you must be on the same side of the world then
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  15. #15

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    20

    Re: timer and capture the letter

    yup 2 more weeks for the school project to end to go attachment

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