Dim startPoint As Integer Dim ar(250) As Double Private Sub Command1_Click() Timer1.Enabled = False End Sub Private Sub Form_Load() startPoint = Picture1.Width - 20 Dim intTemp As Integer For i = 1 To UBound(ar) ar(i) = Rnd(Now()) * 100 Next i End Sub Private Sub Timer1_Timer() startPoint = startPoint - 1 VCenterY = Picture1.Height / 2 '利用定時器周期性地讀取 'Dim tmp As Variant ' CPU資源佔用狀況參數 'tmp = GetUSBData '獲得資料數組 Me.Caption = App.Title & " " & FormatPercent(tmp / 100) ' '在表單標題列用百分比數字形式反映 'Sum = Sum + tmp '累加統計 'Index = Index + 1 '次數統計 'Avg = Int(Sum / Index) '求平均值 Picture1.Cls '清除圖示內容 Picture1.Line (0, VCenterY)-(Picture1.Width, VCenterY), &HBF& Picture1.Line (startPoint, VCenterY)-(startPoint, ar(1)), &HBF& For i = 1 To UBound(ar) - 1 Debug.Print startPoint, ar(i) Picture1.Line (startPoint + i, ar(i))-(startPoint + i + 1, ar(i + 1)), &HBF& Next i End Sub Private Function GetUSBData() As Variant End Function |