I'm a beginner in programming.
I would like to use visual studio 2012 to create a brain training game where I can see arrows in textboxes 5-9 and press the buttons in the order they appear.
In order to use timer to perform the process of changing the textbox foreground from white to black at equal intervals, I entered the following, but the processing was done at once.
Do Until (TextBox5.ForeColor=Color.Black) And (TextBox6.ForeColor=Color.Black) And (TextBox7.ForeColor=Color.Black) And (TextBox8.ForeColor=Color.Black)
Timer1.Enabled=True
TextBox 5.ForeColor=Color.Black
TextBox 6.ForeColor=Color.Black
TextBox 7.ForeColor=Color.Black
TextBox 8.ForeColor=Color.Black
Loop
Timer 1.Enabled=False
I understand that this is not enough, but I don't know how to change the color at equal intervals.
Other than that, I used or statements in the processing part (of course they didn't) and changed them to if statements like "if textboxes 5-9 are white", but the current situation remains the same.
I thought the usage of timer was wrong, but there were no errors at all, and I couldn't find anything to refer to when I searched, so I posted it.
I understand that it is not enough, but I appreciate your cooperation.
What I want to do is to process the following sample code.
The timer performs the actions written in the Tick
event at equal intervals.
The DoUntil
loop takes the action described inside all at once, which is what the question asks.
You may be confused because you have learned a lot about how to use And
and Or
in the If
statement, and how to use timers and process procedures.
Rather than adding all the features you want to implement together, I think adding the code little by little and adding the features while checking the operation will speed up development and understanding.
Public Class Form 1
Private Sub Button 1_Click (sender As Object, eAs EventArgs) Handles Button 1.Click
US>'Timer start
Timer1.Enabled=True
End Sub
Private Sub Timer 1_Tick (sender As Object, eAs EventArgs) Handles Timer 1.Tick
Dim textCursors= New TextBox() {TextBox5, TextBox6, TextBox7, TextBox8}' Array of Color-changing Cursors
'Check TextBox5 to TextBox8 character colors in order and change the first item that is not black.
For Each textBox ContextCursors
If textBox.ForeColor<>Color.Black Then
textBox.ForeColor=Color.Black
Exit For
End If
Next
US>'Timer terminated after changing color for all text boxes
If textCursors.Last.ForeColor=Color.Black Then
Timer 1.Enabled=False
End If
End Sub
End Class
© 2024 OneMinuteCode. All rights reserved.