Option Explicit
Private Sub cmdAddTask_Click()
' We want to add a new task to the list then save it to the registry then
' notify Bill
fraNewTask.Visible = True
bNewTask = True
If bNewTask = True Then
Me.Caption = "Taskmaster™ by D-Code Software -- Adding Task"
lstPriority.AddItem "High"
lstPriority.AddItem "Low"
Else
Exit Sub
End If
End Sub
Private Sub cmdCancel_Click()
fraNewTask.Visible = False
End Sub
Private Sub cmdDelTask_Click()
' This works, except for registry string removal
Dim strMessage As String, strTitle As String
Dim strResult As String
strMessage = "Are you sure you want to delete this task? This will also remove it from the main task list."
strTitle = "Task Removal"
strResult = MsgBox(strMessage, vbYesNo, strTitle)
If strResult = "6" Then
lstToDo.RemoveItem lstToDo.ListIndex ' Remove Item Highlighted
DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\D-Code Software\Taskmaster Server\Tasks", "Task" & lstToDo.ListIndex
Else
Exit Sub
End If
End Sub
Private Sub cmdMarkCompl_Click()
Dim strSelected As String
' Need to make
lstToDo.Selected (lstToDo.ForeColor(lstToDo.Text) = vbRed)
strSelected = lstToDo.ForeColor = vbRed
End Sub
Private Sub cmdOnline_Click()
If cmdOnline.Caption = "Go Online" Then
sckServer.LocalPort = 9001
sckServer.Close ' Close current connection
sckServer.Listen ' Listen on port 9001
cmdOnline.Caption = "Go Offline"
ElseIf cmdOnline.Caption = "Go Offline" Then
sckServer.Close ' Close and shutdown server
cmdOnline.Caption = "Go Online"
Else
Exit Sub
End If
End Sub
Private Sub cmdSaveTask_Click()
intTasks = intTasks + 1
strTaskname(intTasks) = txtTaskName.Text
strTask = CStr(intTasks)
Savestring HKEY_LOCAL_MACHINE, "SOFTWARE\D-Code Software\Taskmaster Server\Tasks", "Task" & intTasks, strTaskname(intTasks)
Savestring HKEY_LOCAL_MACHINE, "SOFTWARE\D-Code Software\Taskmaster Server\Tasks", "Tasks", strTask
fraNewTask.Visible = False
lstToDo.AddItem strTaskname(intTasks)
lstToDo.ItemData(lstToDo.NewIndex) = lstToDo.ItemData(lstToDo.NewIndex) + 20
Debug.Print lstToDo.Text(lstToDo.ListIndex)
End Sub
Private Sub Form_Load()
fraNewTask.Visible = False
lblDate.Caption = Format(Date, "dddd, MMMM d, yyyy")
LoadTasks
If sckServer.State = 2 Then
cmdOnline.Caption = "Go Offline"
Else
cmdOnline.Caption = "Go Online"
End If
End Sub
Private Sub LoadTasks()
' This does not add entries from the registry
Dim intTotalTasks As Integer
intTasks = 0 ' Reset
For intTasks = 1 To 11 - 1
strTask = CStr(intTasks)
strTaskname(intTasks - 1) = Getstring(HKEY_LOCAL_MACHINE, "SOFTWARE\D-Code Software\Taskmaster Server\Tasks\", "Task" & strTask)
If strTaskname(intTasks - 1) <> "" Then
lstToDo.AddItem strTaskname(intTasks - 1)
Else
Exit For
End If
Next intTasks
intTasks = 0
End Sub
Private Sub optDueToday_Click()
If optDueToday.Value = True Then
Me.Caption = "Taskmaster™ by D-Code Software -- Adding Task for " & lblDate
End If
End Sub
Private Sub sckServer_Close()
sckServer.SendData "STATE0"
DoEvents
End Sub
Private Sub sckServer_ConnectionRequest(ByVal requestID As Long)
sckServer.Close
sckServer.Accept requestID
End Sub
Private Sub sckServer_DataArrival(ByVal bytesTotal As Long)
Dim strDataIn As String
Dim strNewData() As String
sckServer.GetData strDataIn
strNewData = Split(strDataIn, ":")
Select Case strNewData
Case "NEWTASK"
Case "DELTASK"
Case Else
Exit Sub
End Select
End Sub
Private Sub tmrTime_Timer()
lblTime.Caption = Format(Time, "hh:mm:ss am/pm")
End Sub