Hi,I have looked around here for the correct way to use Modules and I have not come across anything that seems to point me in the right direction.
I am wondering if I can use modules to define what a button would do but I keep getting the error "ModStart" is not a type and cannot be used as an expression.
I am pretty n00bish at all of this and I am trying to do this as extra curricular activity.
Here is my codes
MainWindow
Public Class MainWindow
'Project Name: OSCE Timer
'
'Version Number: 2.0.0
'
'Author: Daniel Hallam
'
'Description:
' A timer used by medical students for simulating clinical and communication skills examinations.
'
'Notes:
'Phase 1 = Rest time, no visual counting lasts 60 seconds, bell sounds on completion of rest time
'Phase 2 = Examination time, visual counter in tbSecs & tbMins lasts 6 minutes, bell sounds on 5 minutes and completeion 6 minutes.
'
Dim Bell1, bell2, bell3 As Integer ' Specific Time Values for bell sound RestTime1 = 60, bell2 = 360 (6mins), bell3 = 420 (7mins)
Dim i0, i1, Isecs, DSecs As Integer ' Internal Values for equations and text boxes i0 = 0, i1 = 1, i5 = 5
Dim m1, m2, m3, m4, m5 As Integer ' Specific Minute Counter Values m1 = 1 minute, m2 = 2 minutes m3 = 3 minutes m4 = 4 minutes
Dim trackbar, trackbar1, trackbar2, trackbar3, trackbar4, trackbar5 As Integer 'Trackbarvalues
Dim Minute, Minutes, Seconds, nil As String 'label strings
Public Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub bStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bStart.Click
Call ModStart()
'Dim i0 As Integer
'i0 = 0
'tbRest.Text = i0
'If TrackBarRestTime.Value = 0 Or TrackBarExamTimeSettings.Value = 0 Then
' Timer.Stop()
' tbRest.Text = i0
' tbMins.Text = i0
' tbSecs.Text = i0
' MsgBox("You have not selected a time setting!")
' OptionsToolStripMenuItem.Checked = True
' PanelOptions.Show()
'Else
' Timer.Start()
' bStart.Enabled = False
' bResume.Enabled = False
' LoopCheckBox.Enabled = False
' bPause.Enabled = True
' bStop.Enabled = True
' bReset.Enabled = True
' StartToolStripMenuItem.Enabled = False
' ResumeToolStripMenuItem.Enabled = False
' PauseToolStripMenuItem.Enabled = True
' StopToolStripMenuItem.Enabled = True
' ResetToolStripMenuItem.Enabled = True
'End If
Public Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
tbRest.Text = tbRest.Text + i1 ' hidden rest counter
If tbRest.Text > Bell1 Then ' if rest counter = 60
tbSecs.Text = tbSecs.Text + 1 ' then it starts phase 2 counters (visual) +1 per second
End If
If tbSecs.Text = Bell1 Then
tbSecs.Text = i0
End If
If LoopCheckBox.Checked = True And tbMins.Text = m5 Then ' if minute counter = 6 mins and loop is checked then resets visual and hidden counter
tbMins.Text = i0 ' resets counters to 0
tbSecs.Text = i0 ' resets counters to 0
tbRest.Text = i0 ' resets counters to 0
ElseIf tbMins.Text = m5 Then ' if minute counter = 6 mins then stops timer
Timer.Stop()
End If
'Progress Bar ticks & Reset
If tbRest.Text <= Bell1 Then
ProgressBarRestTime.Increment(1)
ProgressBarRestTime.Show()
TextBoxComplete1.Hide()
ElseIf tbRest.Text > Bell1 Then
ProgressBarRestTime.Value = (i0)
ProgressBarRestTime.Hide()
TextBoxComplete1.Show()
End If
If tbRest.Text >= Bell1 Then
ProgressBarExamTime.Increment(1)
ProgressBarExamTime.Show()
TextBoxComplete2.Hide()
ElseIf tbRest.Text = i0 Then
ProgressBarExamTime.Value = (i0)
ProgressBarExamTime.Hide()
TextBoxComplete2.Show()
End If
End Sub
End Sub
^That is not the entire code for the mainwindow, just what I believe is necessary.
Code for the module called on line 25d
Module ModStart
Public Sub StartB(ByVal timer As Timer, ByVal tbRest As TextBox, ByVal TrackBarRestTime As TrackBar, ByVal tbMins As TextBox,
ByVal tbSecs As TextBox, ByVal OptionsToolStripMenuItem As ToolStripMenuItem, ByVal TrackBarExamTimeSettings As TrackBar,
ByVal PanelOptions As Panel, ByVal bStart As Button, ByVal bResume As Button, ByVal bPause As Button, ByVal bStop As Button,
ByVal bReset As Button, ByVal LoopCheckBox As CheckBox, ByVal StartToolStripMenuItem As ToolStripMenuItem, ByVal PauseToolStripMenuItem As ToolStripMenuItem,
ByVal StopToolStripMenuItem As ToolStripMenuItem, ByRef ResetToolStripMenuItem As ToolStripMenuItem, ByVal ResumeToolStripMenuItem As ToolStripMenuItem)
Dim i0 As Integer
i0 = 0
tbRest.Text = i0
If TrackBarRestTime.Value = 0 Or TrackBarExamTimeSettings.Value = 0 Then
timer.Stop()
tbRest.Text = i0
tbMins.Text = i0
tbSecs.Text = i0
MsgBox("You have not selected a time setting!")
OptionsToolStripMenuItem.Checked = True
PanelOptions.Show()
Else
timer.Start()
bStart.Enabled = False
bResume.Enabled = False
LoopCheckBox.Enabled = False
bPause.Enabled = True
bStop.Enabled = True
bReset.Enabled = True
StartToolStripMenuItem.Enabled = False
ResumeToolStripMenuItem.Enabled = False
PauseToolStripMenuItem.Enabled = True
StopToolStripMenuItem.Enabled = True
ResetToolStripMenuItem.Enabled = True
End If
End Sub
End Module
If anyone could explain to my why it does not work (or even if Modules are not supposed to be used in that way)
You may wonder why I am doing it in such a fashion, I am trying to tidy up my code somewhat and if I can cut down on writing all that out in 3 places for the various start controls then I will be happy :)
Thank you in advance.