1 Attachment(s)
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:
Private Sub Form_Load()
' Start the timer.
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
dim i as integer
For i = 0 To 0
' Toggle the color of the letter "A"
If Label1.ForeColor = vbRed Then
Label1.ForeColor = vbBlack
Else
Label1.ForeColor = vbRed
End If
Next i
End Sub
Re: timer and capture the letter
hmmm.. going to lunch now. if nobody answers in one hour, I'll post it.
Re: timer and capture the letter
VB Code:
dim a as integer
Private Sub Form_Load()
a = 0
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
a = a + 1
If Labela.ForeColor = vbRed Then
Labela.ForeColor = vbBlack
Else
Labela.ForeColor = vbRed
End If
Re: timer and capture the letter
1 Attachment(s)
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?
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:
Private Sub Command1_Click()
Label27 = Label1(i).Caption
End Sub
my program code:
VB Code:
Dim i As Integer
Dim time As Double
Option Explicit
Private Sub Command1_Click()
Label27 = Label1(i).Caption
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If i >= Label1.Count Then i = 0
If Label1(i).ForeColor = vbRed Then
Label1(i).ForeColor = vbBlack
Else
Label1(i).ForeColor = vbRed
End If
time = time + 0.5
If time >= 5 Then
time = 0
i = i + 1
End If
End Sub
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
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)
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 :sick:
VB Code:
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
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:
Dim i As Integer
Dim time As Double
Option Explicit
Private Sub Command1_Click()
ShowLetter (i)
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If i >= Label1.Count Then i = 0
Dim t As Integer
For t = 0 To 27
If t <> i Then Label1(t).ForeColor = vbBlack
Next t
If Label1(i).ForeColor = vbRed Then
Label1(i).ForeColor = vbBlack
Else
Label1(i).ForeColor = vbRed
End If
time = time + 0.5
If time >= 5 Then
time = 0
i = i + 1
End If
End Sub
Private Sub Label1_Click(Index As Integer)
i = Index
End Sub
Private Sub ShowLetter(Index)
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
Re: timer and capture the letter
yup that is what i need really thx alot for all the help :eek2:
Re: timer and capture the letter
no problem . slow day at the office
Re: timer and capture the letter
i in my school doing the project slow day for me too 2 more hour to go :cry:
Re: timer and capture the letter
oh? you must be on the same side of the world then
Re: timer and capture the letter
yup 2 more weeks for the school project to end to go attachment ;)