作者Maybetrue (無限大的寂寞)
看板Rubiks
標題[工具] 單機版時距量測軟體 (需要一點DIY喔)
時間Sat Sep 20 11:59:35 2008
這裡提供一個程式碼,讓想要有免費而已且不用連上網路的計時器的玩家
能夠有另一種選擇。請看以下步驟。
首先請先新增一個Excel檔
↓
打開它
↓
左下角有分頁標籤 (例如: sheet1, sheet2...)
↓
在分頁標籤上面按右鍵
↓
選擇「檢視程式碼」
↓
會看到一塊視窗是為了寫VBA用的
↓
在左手邊也有sheet1的標籤
↓
在標籤上按右鍵,選擇新增模組
↓
找到新增的模組雙按它 (按兩下)
↓
在空白處貼上程式碼
↓
按左上角的存檔圖案
↓
這樣主功能就完成了!
建議能夠用一個美工圖案,連結到巨集,以按鈕的方式來操作會比較方便。
這次我把scrambles 的亂數產生公式檢查了一遍,如果有出現奇怪的scramble
麻煩可以站內信告訴我。
使用方法:
我盡量說明怎樣用Excel上面的美工圖案做按鈕。
請先選擇一個美工圖案,並且放到活頁簿空白處。
按右鍵,選擇指定巨集。把指定的巨集選為「CubeCounter」。
這樣就可以用滑鼠按按鈕啟動計時了。
真的看不我的按鈕製作說明,可以去點選巨集,直接執行「CubeCounter」。
但是這樣很麻煩... 。
敲空白鍵可以代替滑鼠去按對話窗的「確定」。這樣方塊塊解完的時候就可以用
敲空白鍵的方式結束計時。
其實我還自己寫了「記錄」按鈕的功能。不過先試試看有沒有人會用CubeCounter吧。
以下code:
---不要複製我,複製下面的部分---
Sub CubeCounter()
Dim scramble As Integer '決定scrambles所使用的整數變數
Dim subscramble As Integer '決定scrambles所使用的整數變數
Dim scrtime As Integer '決定length of scrambles所使用的整數變數
Dim scrguard1 As String '為了避免重複轉同一方向所使用的整數變數
Dim scrguard2 As String '同上
Dim scrguarda As Integer '同上
Dim scrguardb As Integer '同上
Dim scrstring As String '顯示scrambles給使用者的字串變數
Dim scrpassto As String '為了接續(scramble)變數所產生的轉法字串所使用的字
串變數
scrguarda = 0 'Reset Variable
scrguardb = 0
Dim mybtn As Integer
Dim myMsg As String, myTitle As String
Worksheets(1).Activate
Range("A1") = "Length:"
Range("A2") = "scramble:"
Range("G7") = "剛剛的秒數:"
Range("I5") = "最慢:"
Range("I6") = "最快:"
Range("I7") = "平均秒數"
Range("K7") = "資料筆數"
scrtime = Worksheets(1).Range("B1") '取得length of scramble
'
'產生亂數scramble表
'
Do While scrtime > 0
scrtime = scrtime - 1
scrpassto = ""
Randomize
scramble = Int(Rnd() * 9 + 1)
subscramble = Int(Rnd() * 3 + 1)
Select Case scramble
Case 1
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 7 Then
Select Case subscramble
Case 1
If scrguard1 <> "L' " Then
scrpassto = "R "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 <> "L " Then
scrpassto = "R' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 <> "2L " Then
scrpassto = "2R "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 2
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 7 Then
Select Case subscramble
Case 1
If scrguard1 <> "R' " Then
scrpassto = "L "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 <> "R " Then
scrpassto = "L' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 <> "2R " Then
scrpassto = "2L "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 3
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 8 Then
Select Case subscramble
Case 1
If scrguard1 <> "D' " Then
scrpassto = "U "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 <> "D " Then
scrpassto = "U' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 <> "2D " Then
scrpassto = "2U "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 4
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 8 Then
Select Case subscramble
Case 1
If scrguard1 = "U' " Then
scrpassto = "D "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 = "U " Then
scrpassto = "D' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 = "2U " Then
scrpassto = "2D "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 5
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 9 Then
Select Case subscramble
Case 1
If scrguard1 <> "B' " Then
scrpassto = "F "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 <> "B " Then
scrpassto = "F' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 <> "2B " Then
scrpassto = "2F "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 6
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda <> 9 Then
Select Case subscramble
Case 1
If scrguard1 <> "F' " Then
scrpassto = "B "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 2
If scrguard1 <> "F " Then
scrpassto = "B' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
Case 3
If scrguard1 <> "2F " Then
scrpassto = "2B "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Else
scrtime = scrtime + 1
End If
End Select
Else
scrtime = scrtime + 1
End If
Case 7
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda = 1 Or scrguardb = 1 Or scrguarda = 2 Or
scrguardb = 2 Then
scrtime = scrtime + 1
Else
Select Case subscramble
Case 1
scrpassto = "M "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 2
scrpassto = "M' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 3
scrpassto = "2M "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
End Select
End If
Case 8
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda = 3 Or scrguardb = 3 Or scrguarda = 4 Or
scrguardb = 4 Then
scrtime = scrtime + 1
Else
Select Case subscramble
Case 1
scrpassto = "E "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 2
scrpassto = "E' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 3
scrpassto = "2E "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
End Select
End If
Case 9
If scramble = scrguarda Or scramble = scrguardb Then
scrtime = scrtime + 1
ElseIf scrguarda = 5 Or scrguardb = 5 Or scrguarda = 6 Or
scrguardb = 6 Then
scrtime = scrtime + 1
Else
Select Case subscramble
Case 1
scrpassto = "S "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 2
scrpassto = "S' "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
Case 3
scrpassto = "2S "
scrstring = scrstring + scrpassto
scrguard2 = scrguard1
scrguard1 = scrpassto
scrguardb = scrguarda
scrguarda = scramble
End Select
End If
End Select
Worksheets(1).Range("B2") = scrstring
Range("C1") = scrtime
Loop
Worksheets(1).Range("B2") = scrstring
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.152.218.162
※ 編輯: Maybetrue 來自: 61.152.218.162 (09/20 12:00)
※ 編輯: Maybetrue 來自: 61.152.218.162 (09/20 12:02)
推 z753951zxc:推... 09/20 12:22
→ aljohn0422:推.. 09/20 12:31
推 civitcat00:推 我下次來寫c++版本好了... 09/20 12:48
推 a512172598:推推推... 09/20 12:52
推 winiel559: 推... 原PO專業 09/20 21:48
推 WWP:好用!!快出可以記錄的版本吧 09/21 12:32
---以下是記錄功能的巨集---
Sub collector()
Worksheets(1).Activate
Range("F7:G7").Copy Destination:=Range("D9")
Range("B2").Copy Destination:=Range("F9")
Rows(9).Insert
'Range("D9").Select
'Range("D9").Paste
End Sub
---請搭配CubeCounter服用---
※ 編輯: Maybetrue 來自: 61.152.218.162 (09/22 11:10)
推 WWP:哈...正需要可以計時的軟體...感謝 09/22 21:14
※ 編輯: Maybetrue 來自: 220.139.41.38 (10/06 22:25)
※ 編輯: Maybetrue 來自: 61.152.218.162 (10/24 14:33)
※ 編輯: Maybetrue 來自: 61.152.218.162 (10/28 13:54)
※ 編輯: Maybetrue 來自: 61.152.218.162 (10/28 19:47)
※ 編輯: Maybetrue 來自: 61.152.218.162 (10/29 13:33)