Hi everyone, well I have trying to do an elevator simulator, wich have to includo the panel with the floor, available floors, and a button panel with available floors and button up, down, but I dont understand is how to use the timers for up and down, because I vague idea to select the floors is to usea a for or select case but I dont know wich one is the most appropiate in this case. Wha tI have so far is:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer2.Enabled = False
If lbl1.Text = "4" Then
lbl1.Text = "1"
Else
lbl1.Text = Val(lbl1.Text) + 1
End If
Button1_Click("", e)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer1.Enabled = True
If lbl1.Text = "4" Then
lbl1.Text = "1"
Else
lbl1.Text = Val(lbl1.Text) - 1
End If
Button2_Click("", e)
End Sub
Private Sub nvl1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nvl1.CheckedChanged
If nvl1.Checked = True Then
shp1.BackColor = Color.Red
lbl1_nvl1.ForeColor = Color.Red
Else
shp1.BackColor = Color.Green
lbl1_nvl1.ForeColor = Color.Green
shp2.BackColor = Color.Red
lbl2_nvl2.ForeColor = Color.Red
shp3.BackColor = Color.Red
lbl3_nvl3.ForeColor = Color.Red
End If
End Sub
Private Sub nvl2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nvl2.CheckedChanged
If nvl2.Checked = True Then
shp2.BackColor = Color.Red
lbl2_nvl2.ForeColor = Color.Red
Else
shp2.BackColor = Color.Green
lbl2_nvl2.ForeColor = Color.Green
shp1.BackColor = Color.Red
lbl1_nvl1.ForeColor = Color.Red
shp3.BackColor = Color.Red
lbl3_nvl3.ForeColor = Color.Red
End If
End Sub
Private Sub nvl3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nvl3.CheckedChanged
If nvl3.Checked = True Then
shp3.BackColor = Color.Red
lbl3_nvl3.ForeColor = Color.Red
Else
shp3.BackColor = Color.Green
lbl3_nvl3.ForeColor = Color.Green
shp1.BackColor = Color.Red
lbl1_nvl1.ForeColor = Color.Red
shp2.BackColor = Color.Red
lbl2_nvl2.ForeColor = Color.Red
End If
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If lbl1.Text = "1" Then
nvl1.Checked = True
ElseIf lbl1.Text = "2" Then
nvl2.Checked = True
ElseIf lbl1.Text = "3" Then
nvl3.Checked = True
ElseIf lbl1.Text = "4" Then
nvl4.Checked = True
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
If lbl1.Text = "1" Then
nvl1.Checked = True
ElseIf lbl1.Text = "2" Then
nvl2.Checked = True
ElseIf lbl1.Text = "3" Then
nvl3.Checked = True
ElseIf lbl1.Text = "4" Then
nvl4.Checked = True
End If
End Sub
This just shows the levels and the timer1 just go up and a little "screen" shows at what floors is the elevator but this just go up and start from one again.
Thanks in advance for the help.