
Dělám to dobře ?
Štastný 1. svátek, včera před večeří jsem napsal tenhle prográmek (odpočítavadlo) v visual basicu. Ale musel jsem hodně kod kopírovat a vkládal hlavně:
NumericUpDown1.Value = 0
NumericUpDown2.Value = 0
NumericUpDown3.Value = 0
A tak bych se chtěl zeptat zda by jste mi ho mohli zkouknout a popřípadě mi vytknout špatné postupy, učím se tak. :) Díky za chvílku vašeho času.Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (Button1.Text = "Start!") Then
Timer1.Start()
Button1.Text = "Stop"
Label1.Text = "Běží..."
Else
Button1.Text = "Start!"
Timer1.Stop()
Label1.Text = "Zvol čas..."
End If
If (NumericUpDown1.Value = -1) Then
NumericUpDown1.Value = 0
End If
If (NumericUpDown2.Value = -1) Then
NumericUpDown2.Value = 0
End If
If (NumericUpDown3.Value = -1) Then
NumericUpDown3.Value = 0
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
NumericUpDown1.Value = NumericUpDown1.Value - 1
If (NumericUpDown1.Value < 0) Then
NumericUpDown1.Value = 59
NumericUpDown2.Value = NumericUpDown2.Value - 1
End If
If (NumericUpDown2.Value < 0) Then
NumericUpDown2.Value = 59
NumericUpDown3.Value = NumericUpDown3.Value - 1
End If
If (NumericUpDown3.Value < 0) Then
NumericUpDown1.Value = 0
NumericUpDown2.Value = 0
NumericUpDown3.Value = 0
Timer1.Stop()
MsgBox("Čas vypršel!", , "Konec")
Button1.Text = "Start!"
Label1.Text = "Zvol čas..."
Beep()
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If (ComboBox1.Text = "Vynulovat") Then
NumericUpDown2.Value = 0
End If
If (ComboBox1.Text = "Vajička na měkko") Then
NumericUpDown2.Value = 4
End If
If (ComboBox1.Text = "Vajička na tvrdo") Then
NumericUpDown2.Value = 8
End If
If (ComboBox1.Text = "Omeleta :)") Then
NumericUpDown2.Value = 10
End If
NumericUpDown1.Value = 0
NumericUpDown3.Value = 0
End Sub
End Class
