Time Management Small Project (1)

Recently I have been working on a small software, this is about time management. The original intention at the beginning was to write a daily newspaper every day, and then send emails to relevant personnel. It takes time to organize the daily newspapers and send emails, so I decided to develop a small software that saves time. The main function of the software is to realize task reminder, task record, send email after finishing, and send reminder information on DingTalk in time.
My main job is to be responsible for the implementation of the front-end and main functions. After a few days of unremitting efforts, I finally have a small result. The interface is as shown below:
The relevant code is as follows:

Dim Task As String 'Single task content
Dim T1, T2, T3, T4, T5 As String 'Define single task time
Dim n001, n002, n003, n004, n005 As String 'Define the name of a single task
Dim m As String ' Pause time
Dim E As String 'Start time
Dim i As Long 'Task list loop variable in list1
Dim c As String 'The generated log file is named
Dim times As Integer 'Define the number of times the start button is used to determine whether to write pause data
Dim d As Integer
Dim a9 As Integer 'Define a random number to replace the skin

Private Declare Function SkinH_SetAero Lib "SkinH.dll" (ByVal hwnd As Long) As Long
Private Declare Function SkinH_Attach Lib "SkinH.dll" () As Long
Private Declare Function SkinH_AttachEx Lib "SkinH.dll" (ByVal lpSkinFile As String, ByVal lpPasswd As String) As Long

Private Sub Command1_Click()
    FrmRemind.Show 'Open the reminder dialog
End Sub

Private Sub Command2_Click()
    'Check if only one item is selected in the list box
    If List1.SelCount = 1 Then
        List1.RemoveItem List1.ListIndex
    ElseIf List1.SelCount = 0 Then
        MsgBox "Please select a task to delete!", vbOKOnly, "Prompt"
        Exit Sub
    ElseIf List1.ListCount > 1 Then
    'Remove the selected items from the list box
        For i = List1.ListCount - 1 To 0 Step -1
        'Determine whether the item is selected, Selected() returns a boolean value
        If List1.Selected(i) Then
            ' delete the item with index i
            List1.RemoveItem i
        End If
        Next
    End If
End Sub

Private Sub Command4_Click()
    'Record the number of button presses
    times = times + 1
    If List1.ListCount = 0 Then
        MsgBox "Task list is empty!", vbOKOnly, "Prompt"
        Exit Sub
    End If
    If Text2.Text = "" Then
        MsgBox "Please enter the task time!", vbOKOnly, "Prompt"
        Exit Sub
    End If
    'Starting time
    E = Date & Time
    'After the pause, write the pause time and start time to the table
    If Timer1.Enabled = False And times > 1 Then
        Open App.Path & "\c.log" For Append As #1 'Add text to the same file multiple times
        Randomize
         Print #1, "<tr align='center'>" & vbCrLf & _
        "<tr align='center'>" & vbCrLf & _
        "<td>" & "暂停" & "</td>" & vbCrLf & _
        "<td>" & m & "</td>" & vbCrLf & _
        "<td>" & E & "</td>"
        Close #1
    End If
    'Time control on
    Timer1.Enabled = True
End Sub

Private Sub Command3_Click()
    'The task in progress is paused
    Timer1.Enabled = False
    'Record pause time
    m = Date & Time
End Sub

Private Function Rndz(a1 As Long, b1 As Long)
    Rndz = Int((a1 - b1 + 1) * Rnd() + b1)
End Function

Private Sub Form_Load()
    
    Randomize
    
    a9 = Rndz (1, 10)
    'skin initialization
    On Error Resume Next
    File1.Path = App.Path & "\SkinSharp"
    SkinH_Attach
    SkinH_SetAero 1
    SkinH_AttachEx App.Path & "\skin" & "\" & a9 & ".she", ""
    SkinH_AttachEx Command, ""
    'Time control pause
    Timer1.Enabled = False
    Timer4.Enabled = False
    c = Format(Now, "yyyymmdd") 'Assign the current system time (year month day) to c,
    Open App.Path & "\c.log" For Append As #1 'Add text to the same file multiple times
    Randomize
    Print #1, "<p align='center'></p>" & vbCrLf & _
    "<table border='1px'align='center'" & vbCrLf & _
    "bordercolor='blue' width='600px' height='100px'>" & vbCrLf & _
    "<tr align='center'>" & vbCrLf & _
    "<td>内容</td>" & vbCrLf & _
    "<td>Start Time</td>" & vbCrLf & _
    "<td>End Time</td>"
    Close #1
    'Skin file path read
    SkinH_AttachEx App.Path & "\skin" & "\" & a9 & ".she", ""
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     Dim da() As Byte, da1() As String
     Dim ix&, issame As Boolean 'define various variables
     issame = False
     Open App.Path & "\c.log" For Binary As #1
     ReDim da(LOF(1) - 1) As Byte
     Get #1, , da 'Get the data of the file
     Close #1
     da1 = Split(StrConv(da, vbUnicode), vbCrLf) 'Convert data and split with carriage return
     ' You can also use other methods to get the data of each line of the file. However, this method may be faster
     For ix = 0 To UBound(da1) 'Compare each line of data with the content of text
        If da1(ix) = "<p align='center'></p>" Then '& vbCrLf & _
           "<table border='1px'align='center'" & vbCrLf & _
           "bordercolor='blue' width='600px' height='100px'>" & vbCrLf & _
           "<tr align='center'>" & vbCrLf & _
           "<td>内容</td>" & vbCrLf & _
           "<td>Start Time</td>" & vbCrLf & _
           "<td>end time</td>" Then 'If there is the same content, make a mark and exit the loop
           issame = True: Exit For
        End If
     Next ix
     If issame = False Then 'If it is not the same, write the content of the text
        Open App.Path & "\c.log" For Append As #1
        Print #1, "<p align='center'></p>"  '& vbCrLf & _
        "<table border='1px'align='center'" & vbCrLf & _
        "bordercolor='blue' width='600px' height='100px'>" & vbCrLf & _
        "<tr align='center'>" & vbCrLf & _
        "<td>内容</td>" & vbCrLf & _
        "<td>Start Time</td>" & vbCrLf & _
        "<td>End Time</td>"
        Close #1
     'Else' otherwise give a prompt
        'MsgBox "The same record already exists"
     End If
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

End Sub

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325991160&siteId=291194637