首頁>Club>
10
回覆列表
  • 1 # 七夜菌

    操作步驟

    1、新建一個xls的Excel文件,開啟後,切換到【開發工具】,選擇【插入】-【ActiveX控制元件】,在工作表中插入三個大小一樣的【命令按鈕】。可以先插入一個然後拖動的時候,按住【ALT + SHIFT】鍵複製。

    4、在【工程】視窗雙擊工作表下的【Sheet1(Sheet1)】,將以下程式碼貼上到右邊的程式碼視窗,儲存。

    Public StopIt As BooleanPublic ResetIt As BooleanPublic LastTimePrivate Sub CommandButton1_Click()Dim StartTime, FinishTime, TotalTime, PauseTimeStopIt = FalseResetIt = FalseIf Range("b2") = 0 Then StartTime = Timer PauseTime = 0 LastTime = 0Else StartTime = 0 PauseTime = TimerEnd If StartIt: DoEvents If StopIt = True Then LastTime = TotalTime Exit Sub Else FinishTime = Timer TotalTime = FinishTime - StartTime + LastTime - PauseTime TTime = TotalTime * 100 HM = TTime Mod 100 TTime = TTime \ 100 hh = TTime \ 3600 TTime = TTime Mod 3600 MM = TTime \ 60 SS = TTime Mod 60 Range("b2").Value = Format(hh, "00") & ":" & Format(MM, "00") & ":" & Format(SS, "00") & "." & Format(HM, "00") If ResetIt = True Then Range("b2") = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, "00") & "." & Format(0, "00") LastTime = 0 PauseTime = 0 End End If GoTo StartIt End IfEnd SubPrivate Sub CommandButton2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) StopIt = TrueEnd SubPrivate Sub CommandButton3_Click() Range("b2").Value = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, "00") & "." & Format(0, "00") LastTime = 0 ResetIt = TrueEnd Sub顯示開發工具

    如果你的Excel開啟後,找不到【開發工具】,可以在【檔案】-【選項】中,看看【自定義功能區】中【開發工具】前面的勾是否勾選。

  • 中秋節和大豐收的關聯?
  • 準備買個4000左右筆記本,小米和神舟哪家筆記本價效比高呢?