請問,下面的程式碼,執行後,為什麼計時器的時間還是一樣是0?
Private Sub Command1_Click()
Label1 = \"\"
Select Case Len(Text1)
Case Is = 1
a = 900000: b = 90000: c = 9000: d = 900: e = 90: y = 1
Case Is = 2
a = 900000: b = 90000: c = 9000: d = 900: y = 2
Case Is = 3
a = 900000: b = 90000: c = 9000: y = 3
Case Is = 4
a = 900000: b = 90000: y = 4
Case Is = 5
a = 900000: y = 5
Case Is = 6
y = 6
End Select
Timer1.Enabled = True
For i = a To 900000 Step 100000
For j = b To 90000 Step 10000
For k = c To 9000 Step 1000
For l = d To 900 Step 100
For m = e To 90 Step 10
For n = 0 To 9
Select Case y
Case Is = 1
If n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
Case Is = 2
If m + n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
Case Is = 3
If l + m + n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
Case Is = 4
If k + l + m + n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
Case Is = 5
If j + k + l + m + n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
Case Is = 6
If i + j + k + l + m + n = Val(Text1) Then Label1 = \"解碼成功\": x = 1
End Select
If x = 1 Then Exit For
Next n, m, l, k, j, i
Timer1.Enabled = False: Text1.SetFocus
End Sub
Private Sub Timer1_Timer()
Label2.Caption = Str(Val(Label2) + 1)
End Sub
2006-03-04 18:00:26 · 2 個解答 · 發問者 天使 4 in 電腦與網際網路 ➔ 程式設計
表單上的物件佈置:
Text1="0":Label1="":Label2="0":Timer1.Enabled=False
2006-03-04 18:01:56 · update #1
第二個問題:
如何把此程式碼寫得精簡些?
2006-03-04 18:03:12 · update #2
*************************************************
API是什麼?做什麼用的?
2006-03-04 19:14:01 · update #3
你Label2應該是要看解碼時間吧?問題出在現在的電腦太快你迴圈跑完Timer根本還沒動作就被關掉了,所以沒動作,解決的辦法就要動到API,至於簡化程式抱歉小弟實在才殊學淺研究你的CODE很久,還是無法瞭解你要做甚麼,無法幫忙(最好能把註解po上)>*<
Private Declare Function QueryPerformanceCounter Lib "kernel32" (X As Currency) As Boolean
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (X As Currency) As Boolean
Private Sub Command1_Click()
Dim S1 As Currency, S2 As Currency, f As Currency
Label1 = "": y = Len(Text1)
Select Case y
Case Is = 1
a = 900000: b = 90000: c = 9000: d = 900: e = 90
Case Is = 2
a = 900000: b = 90000: c = 9000: d = 900
Case Is = 3
a = 900000: b = 90000: c = 9000
Case Is = 4
a = 900000: b = 90000
Case Is = 5
a = 900000
End Select
QueryPerformanceFrequency f
QueryPerformanceCounter S1
For i = a To 900000 Step 100000
For j = b To 90000 Step 10000
For k = c To 9000 Step 1000
For l = d To 900 Step 100
For M = e To 90 Step 10
For n = 0 To 9
Select Case y
Case Is = 1
If n = Val(Text1) Then Label1 = "解碼成功": X = 1
Case Is = 2
If M + n = Val(Text1) Then Label1 = "解碼成功": X = 1
Case Is = 3
If l + M + n = Val(Text1) Then Label1 = "解碼成功": X = 1
Case Is = 4
If k + l + M + n = Val(Text1) Then Label1 = "解碼成功": X = 1
Case Is = 5
If j + k + l + M + n = Val(Text1) Then Label1 = "解碼成功": X = 1
Case Is = 6
If i + j + k + l + M + n = Val(Text1) Then Label1 = "解碼成功": X = 1
End Select
If X = 1 Then Exit For
Next n, M, l, k, j, i
QueryPerformanceCounter S2
Label2 = FormatNumber((S2 - S1) / f, 8) & "秒"
Text1.SetFocus
End Sub
2006-03-06 12:05:58 補充:
應用程式撰寫界面 (Application Program Interface) 的縮寫,這是一組供應用程式使用的命令,用以向電腦的作業系統請求或執行更低層次的存取操作。Microsoft Visual FoxPro API 包含各種命令,允許 C 或組合語言常式與 Visual FoxPro 相互操作。
2006-03-04 03:06:24 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
可以簡述一下你的程式如何運作嗎@@
2006-03-05 17:31:56 · answer #2 · answered by Phoenix 5 · 0⤊ 0⤋