Hi, I was wondering if anybody who is a more experienced VB developer than I would mind casting an eye over my source code and offering any advice on how it could be improved.
The application is timer that runs for 7 minutes, the first minute is phase 1 and is considered rest time where there are no changes to be seen, phase 2 lasts 6 mins and there is a second and minute counter counting up, bells chime at 1, 6 and 7 mins (though visually this is at 0, 5 and 6 mins)
I still need to add all the user controls in such as stop pause and resume, I was wondering if there is a neat way of doing that as in could I put them in another module? to avoid it looking like this (taken from my first attempt at this timer)
'start button console
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bStart.Click
ToolStripLabel2.Enabled = False
bStart.Enabled = False
restwindow.Show()
If CBLoop.Checked Then
BGTimer.Start()
End If
RestTimer.Start()
bPause.Hide()
bResume.Hide()
bStop.Enabled = True
StopToolStripMenuItem.Enabled = True
PauseToolStripMenuItem.Enabled = True
ResumeToolStripMenuItem.Enabled = False
StartToolStripMenuItem.Enabled = False
bPause.Enabled = True
End Sub
here is the code from the current version
Public Class MainWindow
Dim t0, t1, t2, t3, t4, i1, isecs, m1, m2, m3, m4, t5 As Integer
Private Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
t0 = 0
i1 = 1
t5 = 6
t1 = 60
t2 = t1 * 6
t3 = t2 + t1
m1 = t1 * 2
m2 = m1 + t1
m3 = m1 * 2
m4 = m3 + t1
isecs = isecs + i1
tbRest.Text = t0
tbSecs.Text = t0
tbMins.Text = t0
End Sub
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
tbRest.Text = tbRest.Text + i1
If tbRest.Text > t1 Then
tbSecs.Text = tbSecs.Text + 1
End If
End Sub
Private Sub tbSecs_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbSecs.TextChanged
If tbSecs.Text = t1 And Timer.Enabled = True Then
tbSecs.Text = t0
End If
End Sub
Private Sub tbRest_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbRest.TextChanged
If tbRest.Text = t1 Then
My.Computer.Audio.Play(My.Resources.bell, AudioPlayMode.Background)
ElseIf tbRest.Text = m1 Then
tbMins.Text = tbMins.Text + i1
ElseIf tbRest.Text = m2 Then
tbMins.Text = tbMins.Text + i1
ElseIf tbRest.Text = m3 Then
tbMins.Text = tbMins.Text + i1
ElseIf tbRest.Text = m4 Then
tbMins.Text = tbMins.Text + i1
ElseIf tbRest.Text = t2 Then
My.Computer.Audio.Play(My.Resources.bell, AudioPlayMode.Background)
tbMins.Text = tbMins.Text + i1
ElseIf tbRest.Text = t3 Then
My.Computer.Audio.Play(My.Resources.bell, AudioPlayMode.Background)
tbMins.Text = tbMins.Text + i1
End If
End Sub
Private Sub tbMins_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbMins.TextChanged
If CheckBox1.Checked = True And tbMins.Text = t5 Then
tbMins.Text = t0
tbSecs.Text = t0
tbRest.Text = t0
ElseIf tbMins.Text = t5 Then
Timer.Stop()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer.Start()
End Sub
End Class