1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| Public Class Form1
Dim Up As Boolean = True
Dim v As Integer
Dim myform As Form2
Private Sub txtMin_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtMin.TextChanged
If IsNumeric(txtMin.Text) Then
ProgressBar1.Minimum = CInt(txtMin.Text)
End If
End Sub
Private Sub txtMax_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtMax.TextChanged
If IsNumeric(txtMax.Text) Then
ProgressBar1.Maximum = CInt(txtMax.Text)
End If
End Sub
Private Sub buttonAuto_Click(sender As System.Object, e As System.EventArgs) Handles buttonAuto.Click
If Timer1.Enabled Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
If Up Then
v = v + Val(txtIncr.Text)
If v > ProgressBar1.Maximum Then
v = ProgressBar1.Maximum
Up = False
End If
Else
v = v - Val(txtIncr.Text)
If v < ProgressBar1.Minimum Then
v = ProgressBar1.Minimum
Up = True
End If
End If
ProgressBar1.Value = v
UpdateValue()
End Sub
Private Sub txtIncr_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtIncr.TextChanged
If IsNumeric(txtIncr.Text) Then
If Not Val(txtIncr.Text) < Val(txtMax.Text) Then
txtIncr.Text = 10
End If
Else
txtIncr.Text = 10
End If
End Sub
Private Sub buttonPlus_Click(sender As System.Object, e As System.EventArgs) Handles buttonPlus.Click
If (ProgressBar1.Value + Val(txtIncr.Text)) < ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Value + Val(txtIncr.Text)
Else
ProgressBar1.Value = ProgressBar1.Maximum
End If
UpdateValue()
End Sub
Private Sub buttonMoins_Click(sender As System.Object, e As System.EventArgs) Handles buttonMoins.Click
If (ProgressBar1.Value - Val(txtIncr.Text)) > ProgressBar1.Minimum Then
ProgressBar1.Value = ProgressBar1.Value - Val(txtIncr.Text)
Else
ProgressBar1.Value = ProgressBar1.Minimum
End If
UpdateValue()
End Sub
Private Sub UpdateValue()
lblValue.Text = CStr(ProgressBar1.Value)
Application.DoEvents()
End Sub
Private Sub txtTimer_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtTimer.TextChanged
If IsNumeric(txtTimer.Text) Then
Timer1.Interval = Val(txtTimer.Text)
End If
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
myform = New Form2
myform.Show()
End Sub
End Class |
Partager